Boost logo

Boost Users :

Subject: Re: [Boost-users] Scope exit with no capture
From: Bruno Martinez (bruno.uy_at_[hidden])
Date: 2011-11-24 07:43:14


>> It seems scope exit is abandoned.
>
> Not abandoned but carefully looked after.

I'm happy to hear this.

> Scroll down the post
> you're refering to to this line:
>> #define this(x) (this(x))
>
> Check the code in
> http://lists.boost.org/Archives/boost/2009/05/151353.php
> Do we want to go that far?

What do you mean? Note that the limitation that's bothering me is having
an empty capture list, not capturing this.

> Also, there are some limitations (a) "this" must be first in a
> capture list and (b) there is no way you can use "this" inside
> a body if you use C++03 compiler.
>
> So, rather than raising a learning curve for no clear benefit,
> I prefer being explicit and write:
>
> YourClass *this_ = this; BOOST_SCOPE_EXIT((this_)...
> or
> YourClass& self = *this; BOOST_SCOPE_EXIT((self)...

I've not bumped into the this limitation yet. I want a clean way to run
code at exit that needs no access to local variable and captures nothing.

Since my compiler supports lambda, I've adopted the old scopeguard from
loki. It would be great if scope_exit supported & and = capture for all
needed variables as hinted in the documentation as a possibility, or
better yet, reimplement scope_guard, which has better syntax.

Bruno


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net