[sigc] C++0x lambdas



Hello. Is there a way to use value returning C++0x lambdas with libsigc++?

Functions not returning values work fine:

	sigc::slot <void> slot1 = [] () { };
	sigc::slot <void, int> slot2 = [] (int) { };

no compilation problems. However when a return value is added:

	sigc::slot <bool> slot3 = [] () -> bool { return true; };
	sigc::slot <bool, int> slot4 = [] (int) -> bool { return true; };

I end up getting two compilation errors:
	/usr/include/sigc++-2.0/sigc++/functors/slot.h:103:36: error: void value not ignored as it ought to be
	/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251:21: error: return-statement with a value, in function returning 'void'

Is that possible to achieve in some other way, or are lambdas with a return value not supported by libsigc++ yet?

	best regards
		Jakub Łukomski



full output:

In file included from test.cc:1:0:
/usr/include/sigc++-2.0/sigc++/functors/slot.h: In static member function ‘static T_return sigc::internal::slot_call0<T_functor, T_return>::call_it(sigc::internal::slot_rep*) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’:
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110:45:   instantiated from ‘static void* (* sigc::internal::slot_call0<T_functor, T_return>::address())(void*) [with T_functor = main(int, char**)::<lambda()>, T_return = bool, void* (*)(void*) = void* (*)(void*)]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454:7:   instantiated from ‘sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:26:   instantiated from ‘sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’
test.cc:8:57:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103:36: error: void value not ignored as it ought to be
In file included from /usr/include/sigc++-2.0/sigc++/functors/slot.h:7:0,
                 from test.cc:1:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member function ‘sigc::adaptor_functor<T_functor>::result_type sigc::adaptor_functor<T_functor>::operator()() const [with T_functor = main(int, char**)::<lambda()>, sigc::adaptor_functor<T_functor>::result_type = void]’:
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103:36:   instantiated from ‘static T_return sigc::internal::slot_call0<T_functor, T_return>::call_it(sigc::internal::slot_rep*) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110:45:   instantiated from ‘static void* (* sigc::internal::slot_call0<T_functor, T_return>::address())(void*) [with T_functor = main(int, char**)::<lambda()>, T_return = bool, void* (*)(void*) = void* (*)(void*)]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454:7:   instantiated from ‘sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:26:   instantiated from ‘sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = main(int, char**)::<lambda()>, T_return = bool]’
test.cc:8:57:   instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251:21: error: return-statement with a value, in function returning 'void'



-- 
Jakub Łukomski <dev tenku eu>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]