What would be the reason to make scope_exit (also scope_success, scope_fail) to be move constructable?
LogicFan opened this issue · 1 comments
LogicFan commented
For me, it kind of doesn't make sense.
-
I cannot consider the use case for this.
-
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.
-
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.
-
Some other similar
classcurrently in standard, i.e.lock_guarddoes not permit move construct.
tkoeppe commented
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).