Possible Duplicate:
prohibiting instantiation as a temporary object (C++)
I use a Scopeguard for locking like this (simplified):
{ ScopeGuard sg(mutex); // ...critical code }
I accidently typed in some place
{ ScopeGuard(mutex); // ...critical code }
which is valid code but does not extend the lifetime of the ScopeGuard object past the statement.
Question: Is there any pattern that will result in a compiler error or warning if I create a temporary ScopeGuard object like in the second example?