cplusplus/fundamentals-ts

What would be the reason to make scope_exit (also scope_success, scope_fail) to be move constructable?

LogicFan opened this issue · 1 comments

For me, it kind of doesn't make sense.

  1. I cannot consider the use case for this.

  2. it can introduce some dangerous behaviour, i.e.

auto function() {
    int x;
    scope_exit s = [&]() { x -= 1; }
    return s;
}

which can be entirely avoided if we do not allow move construct.

  1. If we do not allow move construct, implementation can have less cost as we can now use the reference of exit function instead of the copy of the exit function.

  2. Some other similar class currently in standard, i.e. lock_guard does not permit move construct.

This issue tracker is for editorial issues only. For technical discussion, please contact either the paper authors or the committee (https://isocpp.org/std/submit-issue).