
Steven Watanabe wrote:
AMDG
Andrey Semashev <andysem <at> mail.ru> writes:
Generally speaking, you are right here. But first, there are many objects that don't throw on copying. And second, it's not always possible to make a copy beforehand. See one of my previous posts for an example (inserting into container yelds an iterator that is to be used in the scope-exit block). So I think the best way is to leave the decision up to user.
I don't understand. Why can't you make a copy right before the scope exit block? I think that for ScopeExit, always passing by reference is correct. At the very least it should be the default.
Passing by reference definitely gets +1 from me. If possible, and does not uglify the syntax, making it default only would be ok. / Johan