I'm trying to understand the implications of the lambda expression in the code snippet below.
The lambda expression captures variables by value rather than by reference otherwise the local variable message is destroyed when foo exits.
What I don't understand is the capture of m_impl. How is it captured by value if the copy ctor of Impl is deleted? Please can someone enlighten me?
void Foo::foo(std::shared_ptr<std::string> message)
{
m_impl->m_thread.send([=] { m_impl->handleMessage(message); });
}
handleMessage is declared as:
void handleMessage(std::shared_ptr<std::string> message)
and m_impl as:
std::unique_ptr<Impl> m_impl;
Impl has its copy constructor and assignment operator deleted.
Aucun commentaire:
Enregistrer un commentaire