I want to use lambda expressions in connection with goocanvas in gtk++. For my understanding this means that I must be able to put my lambda in a sigc++ functor.
I tried something like that:
sigc::slot<bool, const Glib::RefPtr<Goocanvas::Item>& , GdkEventMotion* > slot2=
[]( const Glib::RefPtr<Goocanvas::Item>& item, GdkEventMotion* ev)->bool
{
cout << "Lambda " << endl; return false;
};
((Glib::RefPtr<Goocanvas::Item>&)item1)->signal_motion_notify_event().connect( slot2);
But this will not compile.
Is there a chance to get sigc working with lambdas or better gtkmm directly without the sigc++ intermediate :-)
I found the following code snipped which do the job. I have no idea how this interacts with the sigc++ lib, but I can use it for simple cases. Maybe someone else can take a look on it.
#include <type_traits>
#include <sigc++/sigc++.h>
namespace sigc
{
template <typename Functor>
struct functor_trait<Functor, false>
{
typedef decltype (::sigc::mem_fun (std::declval<Functor&> (),
&Functor::operator())) _intermediate;
typedef typename _intermediate::result_type result_type;
typedef Functor functor_type;
};
}
UPDATE: Libsigc is now able to handle lambas without any additional user code. The above code must be removed if any current versions is used.