$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2023-12-02 21:19:55
On 12/2/23 23:12, Andrzej Krzemienski via Boost wrote:
> Hi All,
> Two observations from reading the docs.
>
> Why do I need a condition in scope_exit when I have a scope_fail?
There is a discussion about this in this section:
In short, scope_fail implies processing a failure event (for whatever
definition of "failure") and scope_exit has no such connotation and can
be used with arbitrary conditions. The different scope guards have
different default conditions, too.
Internally, both scope_success and scope_fail are implemented on top of
scope_exit and leverage its support for custom condition functions.
> I recommend putting warning somewhere in the docs that while using scope
> guards you may inadvertently read an object after move:
>
> std::string checked(std::string name)
> {
> scope::scope_exit g{[&]{
> std::clog << "checked " << name <<std::endl;
> }};
>
> validate(name);
> return name; // name becomes moved-from
> }
Interesting observation, thanks.