Parameters passed to the connect function are wrong!

Started by AlexxanderX, 20 January 2015, 15:54:34


Quoteerror: static assertion failed: Parameters passed to the connect function are wrong!
static_assert(!std::is_same<Func, Func>::value, "Parameters passed to the connect function are wrong!");

I have using this code:
buttonCreate->connect("Pressed", std::bind(&Handler::createNewMap, this), editBoxWidth, editBoxHeight);

void Handler::createNewMap(tgui::EditBox::Ptr editBoxWidth, tgui::EditBox::Ptr editBoxHeight)
{ ... }


The code u used is indeed wrong. Technically the editBoxWidth and editBoxHeight should be part of the std::bind call because you want to bind 3 parameters (this pointer, width and height) and not just one.

But unlike the old bindCallback function, the connect function will take care of binding for you. It is enough to write the following:
buttonCreate->connect("Pressed", &Handler::createNewMap, this, editBoxWidth, editBoxHeight);

The connect function will "detect" that all parameters of the createNewMap function are given and will bind these parameters.