I will begin with an example. Suppose I need to guard a code with a function inside a mutex. There are two ways of implementing this.
#include
#
You could use something like ScopeGuard. (Now somewhat old-fashioned.)
But given how easy and clear it is to construct a specific RAII wrapper for each resource type I would normally do that.
(I don't think boost ever adopted anything like ScopeGuard. With std::function
, lambdas and so on it's easy to do your own.)