Search code examples
c++c++11c++builderc++builder-xe4

lambda equation in c++


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.


Solution

  • 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