From 5ca5b4102b00b36c961cdabcc912214aea0ce19b Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Fri, 22 Apr 2005 13:28:34 +0000 Subject: [PATCH] Optional's Assignment fixed [SVN r28412] --- in_place_factories.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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()