Boost logo

Boost Users :

From: James Sutherland (James.Sutherland_at_[hidden])
Date: 2008-07-11 19:40:43


>
> #include <boost/function.hpp>
> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/bind.hpp>
>
> int main()
> {
> using namespace boost::lambda;
> typedef boost::function< double() > F0arg;
> boost::function< double() > arg1, arg2;
> const double x1=1.1, x2=2.2;
> F0arg f = bind(protect(_1*_2), x1, x2);
> boost::function< double() > func1(f), func2(f);
> F0arg f2 = bind(protect(_1*_2), bind(func1), bind(func2));
> }
>

Any explanation as to why this works and the previous example does
not? It seems that the line of code:
> boost::function< double() > func1(f), func2(f);
is redundant with
> F0arg f = bind(protect(_1*_2), x1, x2);
isn't it? (Clearly not, since it compiles while the earlier version
did not)

Jame


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