Boost logo

Boost :

Subject: Re: [boost] Proposed new RAII Library
From: Andrew Sandoval (sandoval_at_[hidden])
Date: 2012-09-14 14:29:21


Lorenzo Caminiti <lorcaminiti <at> gmail.com> writes:

> Please consider programming:
>
> #define UNARY_SCOPE_EXIT(unary_func, arg) \
> BOOST_SCOPE_EXIT( (&arg) ) { \
> unary_func(arg); \
> } BOOST_SCOPE_EXIT_END
>
> And then:
>
> UNARY_SCOPE_EXIT(CloseHandle, handle);
>
> That way the code for this one specialized use case of Scope Exit
> becomes closer to what your expressed preference is. You can of course
> put this macro #definition into your own little lib
> scope_exit_arity.hpp and re-use it across your different projects :)

Am I the only one who doesn't like using MACROs -- especially multi-line macros,
for things that can be done as well without?

Maybe I'm too old, but it used to be the case that source debuggers really
struggled with macros. You could step over the magic but not into it.

-Andrew Sandoval


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk