Boost logo

Boost Users :

From: James Sutherland (James.Sutherland_at_[hidden])
Date: 2008-07-11 15:44:54


Any thoughts on how to bind some arguments for a function?

Consider the following:

struct A
{
   double operator()( const double a, const double b, const double c )
const
   {
     return a+b+c;
   }
};

int main()
{
   typedef function<double(double,double,double)> F3arg;
   typedef function<double(double,double) > F2arg;
   typedef function<double(double) > F1arg;
   typedef function<double() > F0arg;

   A a;
   const double x1=0.0, x2=1.0, x3=4.0;

   F3arg f3 = bind<double>( a, _1, _2, _3 );
   cout << f3(x1,x2,x3) << endl;

}

How would I take "f3" and bind one argument? Something like:

F2arg f2 = bind<double>( f3, _2, x2 ); // bind x2 to second argument
of f3...


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net