4

Is it possible to iterate through qmap when key and value is a pointer with foreach?

I always get the error: decltype cannot resolve address of overloaded function

template <typename T, typename T1>
bool func(T1* subject, QMap<T*,T1*>* map)
{
    //...
    foreach (T1* a, map->values) {

    }

thank you for helping me

Ini
  • 401
  • 6
  • 17

1 Answers1

3

As Mike pointed out, you need to call map->values() before foreach would even work normally.

foreach operates on references, and QMap::values() returns a list of them. This would work:

foreach (T1 a, map->values()) {
    if (a == *subject)
        ...
}
jonspaceharper
  • 4,007
  • 2
  • 19
  • 38