Link to home
Start Free TrialLog in
Avatar of ambuli
ambuliFlag for United States of America

asked on

Iterator compile error

Hi I am getting a compile error in the assignment.
It is complaining about cannot convert 'const std::pair<const int, void(*)()> to void(*)()

What could be wrong here.

typedef void (*Callback)();
typedef std::map<int, Callback>  listenerMap_t;
typedef std::map<int, Callback>::const_iterator listenerIter_t;



 Callback cb;

    listenerIter_t listenerIter = listenerMap.find(attr);
    if(listenerIter != listenerMap.end() )
    {
        cb = *listenerIter;   <--- error


    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ambuli

ASKER

Thank you.  
Avatar of ambuli

ASKER

Hi evlrix,
Why it has to be ->second ?( I admit I am not very familar with STD.  I am still learning).  Thx.
That was my fault in your last Q - 'find()' returns a 'pair', thus you need 'second' here. Full credit to evilrix for spotting that, no points for this comment please ;o)