title: How to manage mix use of raw pointers and unique_ptr in different class ? (Exceptions ?)
body: <p>I have a container of objects stored with <code>unique_ptr</code>, for simplicity say i have only one object :</p>
  
  <pre><code>class Container { std::unique_ptr&lt;A&gt; ptrA; }
  </code></pre>
  
  <p>I also have class that uses the object. These class take a raw pointer to these objects when they are constructed:</p>
  
  <pre><code>class B { A* a;
  B(*A param) : a(param) }
  </code></pre>
  
  <p>They are created with : <code>B b = B(Container.ptrA.get()  );</code></p>
  
  <p>The Container class is supposed to outlive the <code>class B</code>. However I'd like my whole program not to crash in the case there is an issue or a bug in my class Container and the <code>unique_ptr</code> goes out of scope and get deleted.</p>
  
  <p>My question is about the design you would take to manage this 1% case so my program can try to reload the data and avoid crashing suddenly, would you use exceptions ? If so where would you do try/catch ?</p>
  
  <p>Thanks !</p>