문제

That's from an example of boosts asio. What does [this] mean? why the []?

acceptor_.async_accept(socket_,
    [this](boost::system::error_code ec)
도움이 되었습니까?

해결책

It is a lambda expression used to create a function as an expression

[] is the capture list

A list of symbols can be passed as follows:

  • [a,&b] where a is captured by value and b is captured by reference.
  • [this] captures the this pointer by value
  • [&] captures all automatic variables mentioned in the body of the lambda by reference
  • [=] captures all automatic variables mentioned in the body of the lambda by value
  • [] captures nothing

다른 팁

It is a part of a lambda expression. Look here for more info.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top