title: Circular double linked list with smart pointers in c++
body: <p>Is it possible to create a circular doubly-linked list using smart pointers in C++</p>
  
  <pre><code>struct Node {
    int val;
    shared_ptr&lt;Node&gt; next;
    weak_ptr prev;
  };
  
  shared_ptr&lt;Node&gt; head;
  </code></pre>
  
  <p>But this will have a circular reference of shared pointers and thus not deallocate correctly.  </p>