title: auto_ptr member initialization in constructor body (not in initializators list)
body: <p>I'm wondering the right way to initialize an auto_ptr member in the constructor of my class.
  My class has 2 (or more) auto_ptr instances of different types. And the initialization of one of them deppends on results of the initialization of the first.</p>
  
  <p>To clarify, this is what I'm doing:</p>
  
  <pre><code>class C1 {
  ...
  }
  
  class C2 {
  ...
  }
  
  class Holder {
  private:
    auto_ptr&lt;C1&gt; c1;
    auto_ptr&lt;C2&gt; c2;
  
  public:
    Holder() :
      c1(new C1()),
      c2(NULL)
    {
      int x = this-&gt;c1-&gt;getGeneratedValue1();
      int y = this-&gt;c1-&gt;getGeneratedValue2();
  
      if (x &gt; 0 &amp;&amp; y &gt; 0) {
        auto_ptr&lt;C2&gt; lC2(new C2(true, 10));
        this-&gt;c2 = lC2;
      } else if (x &gt; 0) {
        auto_ptr&lt;C2&gt; lC2(new C2(false, 20));
        this-&gt;c2 = lC2;
      } else if (y &gt; 0) {
        auto_ptr&lt;C2&gt; lC2(new C2(false, 30));
        this-&gt;c2 = lC2;
      } else {
        auto_ptr&lt;C2&gt; lC2(new C2(false, 0));
        this-&gt;c2 = lC2;
      }
    }
  };
  </code></pre>
  
  <p>The example is a little repetitive but that to enforce the dependence between the 2 auto_ptr instances.
  I decided to create a local auto_ptr in the constructor body and transfer the ownership of its managed instance to the class member as soon as I initialize it.</p>
  
  <p>Is that the right way to do that or should I use semothing better/safer?</p>
  
  <p>Thanks very much.</p>