No match for 'operator += poco error

Hi,

I tried to upgrade my projects to OF 0.83 (from 0.74) but I got many compiling errors, in fact each time my add event function is called:

typedef ofEvent‹hEventArgs›  hEvent;
template ‹typename TArgumentsType, class TListenerClass›
void addListener(std::string dictName, std::string eventName, TListenerClass  * listener, void (TListenerClass::*listenerMethod)(TArgumentsType&)){
        hEvent * event = addEvent(dictName, eventName); // event is created, stored in a map and returned
        if(event != NULL) *event += Poco::delegate(listener, listenerMethod); // <- no match for 'operator +=' in 'event += Poco::delegate(TObj*, void (TObj::*)(TArgs&) …
    }

Any ideas ?

Sometimes errors like this in templated functions mean that there is a mismatch between the method signature you are providing and the method signature it is expecting. I’d double check to make sure that the listener methods you are registering match exactly – check for const / non-const, data types, argument count, etc … I’m assuming the listener you are registering should look something like:

void MyClass::myListener(hEventArgs& args);

and you are adding it with:

???.addListener("DictName", "EventName", this, &MyClass::myListener);

Yes, these are the signatures of my listeners.
So I have to verify …

Thank you

I tried everything, I see no error nowhere.

My code worked perfectly in all versions of OF 0.6 and 0.7

In fact, my reason to copy-paste-modify code from ofEventUtils.h was because what I was trying did’nt work:

	template ‹typename TArgumentsType, class TListenerClass›
    void addListener(std::string dictName, std::string eventName, TListenerClass  * listener, void (TListenerClass::*listenerMethod)(TArgumentsType&)){
        hEvent * event = addEvent(dictName, eventName);
        if(event != NULL) 
			ofAddListener(event, listener, listenerMethod); // <- does that mean a nested template ?
    }

we are now using ofDelegate instead of Poco::Delegate, which is is based on poco’s priority events, so that’s probably the cause of your error.

Finally this worked:

	template ‹typename TArgumentsType, class TListenerClass›
    void addListener(std::string dictName, std::string eventName, TListenerClass  * listener, void (TListenerClass::*listenerMethod)(TArgumentsType&)){
        hEvent * event = addEvent(dictName, eventName);
        if(event != NULL) 
			ofAddListener(*event, listener, listenerMethod);	
    }

I just forgot the * before event,

I hate templates and their impossible compiler errors !

1 Like