Ran into a bit of an issue with std::bind when adding a placeholder
My code is kind of big so I’ll just stick to the essentials
#define GETFUNC(a) (std::bind(&app::a, this, std::placeholders::_1))
class button{
button(<other parameters here>, std::function<void(int)>) { ... }
..
std::function<void(int)> onhover;
..
};
class app{
app(){
elements.push_back(buttonPtr( new button(<other parameters>, GETFUNC(onHover) );
..
typedef std::unique_ptr<button> buttonPtr;
std::vector<buttonPtr> elements;
..
void onHover(int i) {}
}
That bit of code fails at std::bind ( that much I got from the error log )
but works if I change:
- all
std::function<void(int)>tostd::function<void()> onHover(int i)toonHover()std::bind(&app::a, this, std::placeholders::_1)tostd::bind(&app::a, this)
Any thoughts on why this happens and how can I fix it?
It’s working fine. Check this and look for differences to your code.