Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-03-14 17:15:59


"Peng Yu" <pengyu.ut_at_[hidden]> wrote

> I'm made up the following example. But it's not working. Could you
> please show me how to make it work?

> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/core.hpp>
> #include <iostream>
>
> using namespace boost::lambda;
>
> int main() {
> std::cout << (_1 + _2)(10, 10) << std::endl;
> }

The function object -- the result of _1 + _2 -- requires T&, and therefore
you can't pass constants to it. The following will work:

int n1 = 10;
int n2 = 10;
cout << (_1 + _2)(n1, n2) << endl;

HTH,
Arkadiy


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