
Thorsten Ottosen wrote:
"Alberto Barbati" <abarbati@iaanus.com> wrote in message news:c2gk5o$6v4$1@sea.gmane.org...
That is good. However, I think that such optimization is unnecessary. For primitive types, the destructor is trivial and the copy constructor is the assignment, so I bet a reasonably good compiler can optimize the dtor/ctor idiom to a simple assigment even without any "help" in the form of template machinery. Besides, bad compilers may introduce pessimizations... ;)
The cases where a call to a destructor is actually important beacuse it does some non-trivial work, one really need to ensure not even temporary objects of the type exists. That's one of the capabilities my smart containers will allow, ie, "overwriting" really means destructing and replacing.
I'm sorry, I don't understand what you are trying to say here. I started my sentence with "For primitive types"... Alberto