title: Singly Linked List using shared_ptr
body: <p>I was trying to implement singly linked list using <code>share_ptr</code>. Here is the implementation...
  Below is the node class...</p>
  
  <pre><code>template&lt;typename T&gt;
  class Node
  {
  public:
      T value;
      shared_ptr&lt;Node&lt;T&gt;&gt; next;
      Node() : value(0), next(nullptr){};
      Node(T value) : value(value), next(nullptr){};
      ~Node() { cout &lt;&lt; "In Destructor: " &lt;&lt; value &lt;&lt; endl; };
  };
  </code></pre>
  
  <p>Below is the linked list class...</p>
  
  <pre><code>template&lt;typename T&gt;
  class LinkedList
  {
  private:
      size_t m_size;
      shared_ptr&lt;Node&lt;T&gt;&gt; head;
      shared_ptr&lt;Node&lt;T&gt;&gt; tail;
  public:
      LinkedList() : m_size(0), head(nullptr) {};
      void push_front(T value)
      {
          shared_ptr&lt;Node&lt;T&gt;&gt; temp = head;
          head = make_shared&lt;Node&lt;T&gt;&gt;(Node&lt;T&gt;(value));
  
          head-&gt;next = temp;
          m_size++;
  
          if (m_size == 1)
              tail = head;
      }
      void pop_front()
      {
          if (m_size != 0)
          {
              // Here I am having doubt------------------------!!!
              //shared_ptr&lt;Node&lt;T&gt;&gt; temp = head;
              head = head-&gt;next;
              m_size--;
              if (m_size == 0)
                  tail = nullptr;
          }
      }
      bool empty()
      {
          return (m_size == 0) ? true : false;
      }
      T front()
      {
          if (m_size != 0)
              return head-&gt;value;
      }
  };
  </code></pre>
  
  <p>My question is, am I using the <code>shared_ptr</code> properly for allocating a node? If not, how should I use the <code>shared_ptr</code> to allocate and how should I delete the node in the <code>pop_front</code> method?</p>