How would I catch a member variable by value when using C++0x lambdas?
Using the [=my_member] syntax doesn't seem to work, and implicit capture uses the "this" pointer. What is need is a way to explicitly specify capture type of member variables. Is that possible?
My workaround for now is:
void member_function()
{
std::shared_ptr<my_member_class> my_member_copy = my_member; // this shouldn't be necessary
std::async([=]{ std::cout << *my_member_copy; });
// std::async([=]{ std::cout << *my_member_; }); // wrong, my member could be potentially out of scope
}
EDIT: Clearified question