I
Igor R.
Hello,
I'm trying to convert some parts of a legacy code to use c++0x
lambdas. The original line looks like this:
someQueue_->post(bind(&MyClass::func, shared_from_this()));
When converting, I certainly have to keep the "binding" with
shared_ptr. I intend to do this as follows:
auto self = shared_from_this();
someQueue_->post([&, self] {func()});
However, my concern is that the captured but unused "self" may be
omitted by c++ compiler during the optimization. I'd appreciate if
someone familiar with the relevant specs could shed some light on
this.
Thanks.
I'm trying to convert some parts of a legacy code to use c++0x
lambdas. The original line looks like this:
someQueue_->post(bind(&MyClass::func, shared_from_this()));
When converting, I certainly have to keep the "binding" with
shared_ptr. I intend to do this as follows:
auto self = shared_from_this();
someQueue_->post([&, self] {func()});
However, my concern is that the captured but unused "self" may be
omitted by c++ compiler during the optimization. I'd appreciate if
someone familiar with the relevant specs could shed some light on
this.
Thanks.