Using function operator in lambda expression
Hi.
According lambda documentation
<http://www.boost.org/doc/libs/1_38_0/doc/html/lambda/le_in_details.html
#lambda.operator_expressions> there is a possibility to use function
call operator in lambda expression. But I can't compile following code
using MS Visual Studio 2003.NET compiler:
#include
On Thu, Jun 2, 2011 at 12:32 PM, Alexander Khomyak < Alexander.Khomyak@cbossgroup.com> wrote:
Hi.
According lambda documentationhttp://www.boost.org/doc/libs/1_38_0/doc/html/lambda/le_in_details.html#lamb...there is a possibility to use function call operator in lambda expression. But I can’t compile following code using MS Visual Studio 2003.NETcompiler:
#include
using namespace boost::lambda;
int foo(int i) { return i; }
Somewhere in main function:
(_1(1))(foo);
Could you give me example of using function call operator in lambda expression?
In advance thank you very much.
I don't believe this is possible. The documentation states... *The function call operators have the effect of evaluating the lambda functor. * from which I infer that the result of application of function-call is no longer a lazy object. You can write (_1(foo))(1); but I guess that's not quite what you had in mind. HTH - Rob.
"Alexander Khomyak" wrote:
According lambda documentation <http://www.boost.org/doc/libs/1_38_0/doc/html/lambda/le_in_details.html #lambda.operator_expressions> there is a possibility to use function call operator in lambda expression. ... (_1(1))(foo);
_1 is can be seen as a function object that returns its first argument. _1(1) calls that function object with 1, the result of which is 1. I think this is what you want: bind(_1, 1)(&foo); // Equivalent to foo(1) You have to include boost/lambda/bind.hpp to use bind.
participants (3)
-
Alexander Khomyak
-
Niklas Angare
-
Robert Jones