Project

General

Profile

lambda functions bound to signals

Added by Garrett Mc over 12 years ago

I've asked this kind of stuff before, but I'm hoping you can give me some way out. I attempted to bind standard lambda functions functions to slots using both the SLOT() macro and boost::bind() but unfortunately the .connect() functionality can't actually handle the lambda functions so compilation fails. Replacing these lambda's with void functions in the application model works, and right now that is fine but I'm worried it will become crufty quickly as slot bindings get moved around and zombie code begins building up in my application model. It would be very welcome to see 0X/11 support on at least an optional 'set this flag to true' basis. Previously it's been noted that there is no way for this to be tested for, apparently there is a 'standard friendly' way to do this using the __cplusplus language level macro. However in the land of GNU gcc/g, there has been a bug in the compiler that persisted until 4.7.0. It's been fixed, but not unless you are running the latest 4.7.x versions (ie, the version present in Fedora 17).

Sorry for making myself a pest on this and thanks again for the great framework,

-Garrett


Replies (3)

RE: lambda functions bound to signals - Added by Wim Dumon over 12 years ago

Hello Garet,

What syntax are you using for lambdas? Did you read http://www.webtoolkit.eu/wt/blog/2010/08/06/wt_and_c__0x ?

C++11 is new for us too - suggestions for improvements are welcomed.

BR,

Wim.

RE: lambda functions bound to signals - Added by Garrett Mc over 12 years ago

I had missed the blogpost discussing this. However a quick cut + paste got me back to my original error. Specifically I get the error \"no match for call to '(WtBase::initCount()::<lambda()>)(Wt::NoClass&)' Candidate is: WtBase::initCount()::<lambda()>

However this appears like it's either a bug on my end (failing to capture the event perhaps?) or a hangup with the particular version of boost I'm running, based on the blog post in question. I'll keep digging and see if I can track this down. Thanks for the response!

-Garrett

RE: lambda functions bound to signals - Added by Garrett Mc over 12 years ago

And like that I think I've solved it. I had an extraneous '()' and was setting up my lambda as '[=] (){}' instead of '[=]{}'.

-Garrett

    (1-3/3)