
2012/9/16 Sohail Somani <sohail@taggedtype.net>:
On 15/09/2012 1:55 PM, Lorenzo Caminiti wrote:
I wouldn't add the dismiss functionality. That is not always needed with RAII and the Scope Exit API is more generic without it. If users need such functionality, they can use a commit/dismiss variable external to Scope Exit to simply implement it:
Every scope guard since the beginning of time has had a dismiss/release function.
Pardon me but writing an extra line is exactly what I'm trying to avoid.
Similarly, one might argue that every string class should have a trim member function, but then there are good arguments, that algorithms like trim should be external functions [1]. So, maybe the dismiss functionality can be an external function (assuming a guard can be rebound to another function): void do_nothing() {} void dismiss( guard& ) { guard = do_nothing; } Regards, Kris [1] http://www.gotw.ca/gotw/084.htm