Is there a way to refer to the closure object from inside its operator()
?
Simplified version of what I'd like to do with Boost.Asio
:
tcp::acceptor acceptor;
auto handler = [&acceptor]( )
{
// ...
acceptor.async_accept( *this );
};
acceptor.async_accept( handler );
But there is no separate this
for lambdas.
And I cannot capture reference to handler, because its type isn't yet known.
The only workaround I see now is to write separate functor class, simply because there is a this
-pointer.