From 5ca5b4102b00b36c961cdabcc912214aea0ce19b Mon Sep 17 00:00:00 2001
From: Fernando Cacciola
struct C { - C() : contained_(0) {} - C ( X const& v ) : contained_ ( new X(v) ) {} - template<class InPlaceFactory> C ( InPlaceFactory const& aFactoty ) : @@ -128,11 +125,15 @@ The following simplified example shows the basic idea. A complete example follow aFactory.template apply<X>(contained_); } - ~C() { delete contained_ ; } + ~C() + { + contained_ -> X::~X(); + delete[] contained_ ; + } - X* uninitialized_storage() { return static_cast<X*>(new char[sizeof(X)]) ; } + char* uninitialized_storage() { return new char[sizeof(X)] ; } - X* contained_ ; + char* contained_ ; } ; void foo()