1

I am learning some C++ code which uses boost library. And there are some code like this:

getService().post( [=] {...} )

getService() is a function which returns an io_service of boost library. I want to know what this symbol "[=]" means in C++?

kylejan
  • 163
  • 1
  • 13

1 Answers1

5

That means that the lambda expression captures values by assignment. Another option is to capture by reference using [&]. There are many variations on this, instead of listing them all here, I'll point you at this quality answer: What is a lambda expression in C++11?

Community
  • 1
  • 1
Lance
  • 8,872
  • 2
  • 36
  • 47
  • `[]` captures nothing, `[&]` captures everything by reference, `[a, &b]` captures only some variables – o11c Oct 13 '14 at 03:20