need help with lambda object

View: New views
1 Messages — Rating Filter:   Alert me  

need help with lambda object

by Ofer Oshri-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hi,
i need to add 2 integers through a lambda object.  the first integer parameter comes from the input.  the second one comes from a function that takes no parameter and return integer.  the only solution i could think of is as follows:

//////////////////////////////////////////////////////////////////
#include <iostream>
#include <sigc++.h>

int f() { return 8; }
int g(int a, int b) { return a + b; }

int main()
{
   std::cerr << "y=" << sigc::bind<-1>(sigc::group((sigc::_1 + sigc::_2),sigc::_1, sigc::group(sigc::hide<0>(sigc::ptr_fun(&f)), sigc::_2)), 0)(1) << std::endl;
}

my problem with the above solution is that i have to pass and hide sigc::_2 from f() and to use bind for the redundant input parameter.  is there a better solution?
thanks in advance,
ofer


     
_______________________________________________
libsigc-list mailing list
libsigc-list@...
http://mail.gnome.org/mailman/listinfo/libsigc-list