Possible Duplicate:
How to disallow temporaries in C++
There are times when I meant to write something like
{
MyClass anInstance( param );
// other code...
}
but actually wrote
{
MyClass( param );
// other code...
}
As a result, the destructor was called immediately after the destructor, instead of at the end of the scope. Is there any way to write the class to make this error produce a compile error? Failing that, maybe an optional warning I can turn on? (I'm using Clang on Mac OS X.)