0

I have this code.

boost::for_each(
    boost::make_iterator_range(
            func(arg1),
            func(arg2)
        ),
        [&d, &f](const a<b>& c)
        {
            something;
        }
);

I understand the iterator part of the code. What is not clear to me is over what we iterate. What does this construction mean? [](){}

Roman
  • 124,451
  • 167
  • 349
  • 456
  • 1
    [This question](http://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11) has a pretty good explanation. – chris Mar 13 '13 at 15:31

1 Answers1

2

This is a lambda-expression , an anonymous method/function. You can provide it inline if there is no reason to define a distinct function. [] binds the local parameters either by value [] or by reference [&]. In () you pass your values like in a function call and {} embraces the function body.

See here.

David G
  • 94,763
  • 41
  • 167
  • 253
bash.d
  • 13,029
  • 3
  • 29
  • 42