[sigc] need help with lambda object
- From: Ofer Oshri <ofer_oshri yahoo com>
 
- To: libsigc-list gnome org
 
- Subject: [sigc] need help with lambda object
 
- Date: Sun, 21 Jun 2009 11:44:22 -0700 (PDT)
 
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
      
[Date Prev][Date Next]   [Thread Prev][Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]