title: C++ Singly Linked List - Deque - InsertFront()
body: <p>I'm trying to implement an insertfront() function for my singly list deque but I keep running into this one same problem.</p>
  
  <p>I believe its due to the overloading of the operator=</p>
  
  <p><code>Deque&amp; operator=(const Deque&amp;){return *this;};</code> </p>
  
  <p>For the assignment to work it requires operand A to be a reference of type Deque and operand B to be another reference of type Deque but I'm unsure on how to go about implementing this as I tried to do head&amp; = new_node&amp; and got hit with more errors. </p>
  
  <pre><code>Deque.cpp||In member function 'void Deque::insert_front(int)':|
  Deque.cpp|21|error: use of deleted function 'std::unique_ptr&lt;_Tp, _Dp&gt;&amp; std::unique_ptr&lt;_Tp, _Dp&gt;::operator=(const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;) [with _Tp = Node; _Dp = std::default_delete&lt;Node&gt;]'|
  /usr/include/c++/6/bits/unique_ptr.h|357|note: declared here|
  </code></pre>
  
  <p>Here is my function </p>
  
  <pre><code>#include "Deque.h"
  #include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;utility&gt;
  using std::cout;
  using std::endl;
  using std::move;
  
  void Deque::insert_front(int a)
  {
      std::unique_ptr&lt;Node&gt; new_node;
  
      new_node-&gt;val = move(a);
  
      new_node-&gt;next = move(head);
      head = move (new_node);
  }
  </code></pre>
  
  <p>Deque.h</p>
  
  <pre><code>#include "Node.h"
  #include &lt;memory&gt;
  class Deque{
      public:
          Deque() = default;
          Deque(const Deque&amp;);
          ~Deque(); //must use constant space
          Deque&amp; operator=(const Deque&amp;){return *this;};
          void insert_front(int); 
  
      private:
  
      friend Node;
  
          //Sentinel
          std::unique_ptr&lt;Node&gt; head ;
          std::unique_ptr&lt;Node&gt; tail ;
  };
  </code></pre>
  
  <p>Node.h</p>
  
  <pre><code>#ifndef NODE_H
  #define NODE_H
  
  #include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  class Node {
   public:
   Node(const Node&amp; n) : val{n.val}, next{}
    {
    }
   Node(int v, std::unique_ptr&lt;Node&gt; n) : val{v}, next{move(n)}
    {
    }
   Node(int v) : val{v}
    {
    }
  
   private:
    int val = 0;
    std::unique_ptr&lt;Node&gt; next = nullptr;
  
    friend class Deque;
    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const Node&amp;);
  };
  
  #endif
  </code></pre>