I would like to use lambda equation. In the C++ Builder XE4, I tried the following.

#include <boost/mpl/lambda.hpp>

auto add = [] (int a, int b)-> int{ return a + b; };

However, I got "E2188: Expression syntax" error.

What is the problem?

I am sure that the boost library is correctly installed on my environment.

有帮助吗?

解决方案

There is no issue with code. Compile with c++11.

auto add = [] (int a, int b)-> int{ return a + b; };
cout<<add(2,3);

http://ideone.com/PGSmXh
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top