Hm, I see code like this:
// final_act allows you to ensure something gets run at the end of a scope
template <class F>
class final_act
{
public:
explicit final_act(F f) noexcept : f_(std::move(f)), invoke_(true) {}
final_act(final_act&& other) noexcept : f_(std::move(other.f_)),
invoke_(other.invoke_)
{
other.invoke_ = false;
}
final_act(const final_act&) = delete;
final_act& operator=(const final_act&) = delete;
~final_act() noexcept
{
if (invoke_) f_();
}
private:
F f_;
bool invoke_;
};
I don't like that they've renamed ScopeGuard to something else. More
names to learn, not easily recognized, and the new name points in a
misleading direction.
I don't like that there's no reference to Marginean and Alexandrescu.
I don't like that they've removed the trivial but important `dismiss`
method. That's like wanton destruction, in the usual Microsoft style.
Apparently the authors don't understand the concept here. :(
I don't like that they've simply added `noexcept` to the destructor,
apparently just for conformity's sake. For example, `final_act`
augmented with a `dismiss` method can't be used to implement a
transaction, when roll-back can fail, without an elaborate scheme for
propagating an exception across the `noexcept` barrier. The original
ScopeGuard wasn't perfect in that way, either, because it just
unreasonably /swallowed/ exceptions from the cleanup function (as I
recall Andrei didn't see that as a problem at all when I asked him about
it), but at least it didn't default to crashing the program, preventing
larger scale cleanup, on a little local cleanup failure.
If this library becomes widely used, as is possible, then it will again
be that competent people can't just rely on the common infra-structure
but must re-create parts of it to have something practically useful.
[snip]
Cheers!,
- Alf