[bind][lambda] overriding return value
Hi, Is it possible to override/generate a return value? I want to connect a signal that has a bool return value to a method that has a void return type, generating always a true return. class X { public: void f(); }; boost::signal< bool () > sgn; X x; sgn.connect( boost::bind( &X::f, &x ) ); // error, signal has bool return, method doesn't David
AMDG David Rodríguez Ibeas wrote:
Hi,
Is it possible to override/generate a return value? I want to connect a signal that has a bool return value to a method that has a void return type, generating always a true return.
class X { public: void f(); }; boost::signal< bool () > sgn;
X x; sgn.connect( boost::bind( &X::f, &x ) ); // error, signal has bool return, method doesn't
Using lambda, you can use the comma operator. sgn.connect((boost::lambda::bind(&X::f, &x), true)) In Christ, Steven Watanabe
On Mon, Jul 21, 2008 at 9:28 PM, Steven Watanabe
David Rodríguez Ibeas wrote:
Hi,
Is it possible to override/generate a return value? I want to connect a signal that has a bool return value to a method that has a void return type, generating always a true return.
class X { public: void f(); }; boost::signal< bool () > sgn;
X x; sgn.connect( boost::bind( &X::f, &x ) ); // error, signal has bool return, method doesn't
Using lambda, you can use the comma operator.
sgn.connect((boost::lambda::bind(&X::f, &x), true))
That's brilliant - I needed exactly this last month! I wish I'd thought of that! Cheers, Rob.
participants (3)
-
David Rodríguez Ibeas
-
Robert Jones
-
Steven Watanabe