i know the minimal basics of a lambda function, could someone give me the breakdown of each part in the function

Recommended Answers

All 2 Replies

In

// ...
int x = 8 ;
int y = 9 ;
auto foobar = [ &x, y ]( int a, int b ) { return x += a + b + y ; }
// ...

[ &x, y ] specifies the identifiers declared outside the lambda function that will be available to the lambda (closure). In this example, the lambda function captures x by reference and y by value ( int a, int b ) is the parameter list of the lambda function { return x += a + b + y ; } is the lambda function's body

see: http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions

why use an auto to do this... your essentially returning an int are you not.
when when trying to use an int does it throw an error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.