sevenOfNine
sevenOfNine

Reputation: 1554

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.

Upvotes: 1

Views: 700

Answers (1)

shivakumar
shivakumar

Reputation: 3387

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

Upvotes: 1

Related Questions