Need Help with std::bind in Wt
Added by Manoj G over 11 years ago
Hi,
I am trying to build a small application with Wt. Following code works well in Ubuntu, but not with the CentOS with g version 4.4.7,
button->clicked().connect([=] (const Wt::WMouseEvent& e) {
host_ = Wt::asString(host->text()).toUTF8();
port_ = Wt::asString(port->text()).toUTF8();
user_ = Wt::asString(user->text()).toUTF8();
pass_ = Wt::asString(pass->text()).toUTF8();
db_ = Wt::asString(db->text()).toUTF8();
table_ = Wt::asString(tb->text()).toUTF8();
rFunction();
vizFunction();
});
In CentOS, I'm getting the following error,
error: expected primary-expression before '[' token
error: expected primary-expression before '=' token
error: expected primary-expression before ']' token
I have very little experience in C, having hard time in understanding these.
Any work around to solve this?
Thank you,
Manoj G
Replies (2)
RE: Need Help with std::bind in Wt - Added by Wim Dumon over 11 years ago
Hello Manoj,
This construction with [=]{} are lambda functions, which have been standardized quite recently in c+11 (thus in 2011). Only recent C+ compilers can use them - lambdas were first available in gcc 4.5.
The alternative to lambda functions is to connect your signal to member functions, as is demonstrated in Wt's hello.C 'hello world' application.
Best regards,
Wim.
RE: Need Help with std::bind in Wt - Added by Manoj G over 11 years ago
Thanks a lot Wim. That helped.
Regards,
Manoj G