title: How should a unique ptr class pass its instance pointer to its member objects
body: <p>How should a unique ptr class pass its instance pointer to its member objects.
  I came up with the following way and wanted to know if there was a better way.
  In the following example the object f is passing its instance ptr to its member object as a raw pointer. I wanted to know if this is ok or is there a better and safer way of doing this ?</p>
  
  <pre><code>class bar;
  
  struct foo
  {
      std::unique_ptr&lt;bar&gt; bar_ptr;    
  };
  
  struct bar
  {
     const foo* raw_foo_ptr;
     bar()  {   }
     void setfoo(const foo* p)
     {raw_foo_ptr = p;}
  };
  
  int main()
  {
      std::unique_ptr&lt;foo&gt; f(new foo());
      f-&gt;bar_ptr.reset(new bar());
      f-&gt;bar_ptr-&gt;setfoo(f.get());
  }
  </code></pre>