diff --git a/in_place_factories.html b/in_place_factories.html index 396afbb..9b71559 100644 --- a/in_place_factories.html +++ b/in_place_factories.html @@ -117,9 +117,6 @@ From the user POV, it amounts to creating the right factory object to hold the p The following simplified example shows the basic idea. A complete example follows the formal specification of the framework:
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()