vendredi 19 avril 2019

How to encapsulate function binding?

I have:

std::function<void(EventCustom*)> f = std::bind( &MyClass::MyFunc, myObj, _1 );

The above line is used throughout my code, but instead of MyClass, it may be MyClass2, MyClass3, myObj3,myObj2 etc used in place of MyClass and myObj

Is there some way I can wrap the above in a function ? The problem I am having is, unless I use the code exactly as written above, the output of bind does not exactly create an std::function, so the compiler complains.

EventCustom* is an object used in the cocos2d-x library. So if you download and build a cocos2d-x project you can use it.

Aucun commentaire:

Enregistrer un commentaire