|
Boost : |
Subject: Re: [boost] [scope_exit] D-style scope(failure) and scope(success) in C++
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2013-09-26 17:55:02
On Thu, Sep 26, 2013 at 5:58 AM, Sergey Cheban <s.cheban_at_[hidden]> wrote:
> On 02.10.2012 16:53, Evgeny Panasyuk wrote:
>
>> Currently BOOST_SCOPE_FAILURE and BOOST_SCOPE_SUCCESS are implemented
>> based on boost_1_51_0/boost/scope_exit.hpp by copy-paste and replace
>> (just for proof-or-concept, of course it is possible solution with much
>> less duplication).
>> Semantically meaningful changes can be viewed as diff at
>>
>> https://github.com/panaseleus/stack_unwinding/commit/d5513404323490ea99d9b6b77ff1b88f454a4a42
>
> Any progress on this?
As far as I understand it, this cannot be implemented (at least in a
portable way). See:
Boost.ScopeExit is similar to scope(exit) feature built into the D
programming language.
A curious reader may notice that the library does not implement
scope(success) and scope(failure) of the D language. Unfortunately,
these are not possible in C++ because failure or success conditions
cannot be determined by callingstd::uncaught_exception (see Guru of
the Week #47 for details about std::uncaught_exception and if it has
any good use at all). However, this is not a big problem because these
two D's constructs can be expressed in terms of scope(exit) and a
boolcommit variable (similarly to some examples presented in the
Tutorial section).
HTH,
--Lorenzo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk