Boost logo

Boost :

Subject: Re: [boost] Proposed new RAII Library
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-09-14 18:21:21

On Fri, Sep 14, 2012 at 2:02 PM, Andrew Sandoval
<sandoval_at_[hidden]> wrote:
> Vicente J. Botet Escriba <vicente.botet <at>> writes:
>> I don't know if I will use in my code the proposed scope_guard interface
>> having as parameters a function and its arguments, as in
>> boost::scope_guard kanyewest(CloseHandleIfNot, dismiss, handle);
> Vincente: I am a little confused. Are you suggesting that you will write these
> new classes, or that I should put this in mine? The one I sent originally has a
> dismiss method, it's just called Cancel(). It also has operator=.
> And while it would only work with C++11 compilers using lambdas, if you were
> using boost::bind it would work with C++03 compilers as well.

No, it won't because with C++11 you can execute *arbitrary* copy at
scope exit while with bind you can execute a function with arbitrary
arity but still just execute a function a scope exit. How do I state
this more clearly?? Well say with bind you can't do:

if (...) { f(); int x = 1; } else {...}
for (...) ...

(Phoenix might help but that's like trying to use lamba expressions on C++03.)

> Since I proposed this I will work on changing my two classes (RAIIWrapper and
> RAIIFunction) so that they comply better with the C++ Library standards
> (nomenclature, etc.) and I will submit that for review. I am completely open
> however to putting it an existing library, though I think it might help if we
> Boost had an RAII library that contained these two classes AND in the
> documentation links to other RAII containers like scoped_ptr, shared_ptr, and
> Boost.ScopedExit.

Really HTH,

Boost list run by bdawes at, gregod at, cpdaniel at, john at