title: C++ Use of deleted function error
body: <p>I'm getting a lot of use of deleted function error. I just changed the pointer of <code>weighted_pointer</code> to <code>unique_ptr</code>. But I can't realize why I'm getting the error, any tip?</p>
  
  <p>The <code>likeatree</code> is a DAG structure which can point to another struct or an element of <code>stdDeque</code> based on mask value.</p>
  
  <p>The <code>weight</code> of <code>weighted_pointer</code> has <code>mutable</code> keyword because doesn't change where in the set will be.</p>
  
  <pre><code>#include &lt;deque&gt;
  #include &lt;set&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;memory&gt;
  #include &lt;chrono&gt;
  
  using namespace std;
  
  struct likeatree{
      unsigned int mask : 3;
      void * a;
      void * b;
  };
  
  struct weighted_pointer{
      mutable int weight;
      unique_ptr&lt;likeatree&gt; ptr;
  };
  
  struct ptrcomp{
      bool operator()(const weighted_pointer &amp; lhs, const weighted_pointer &amp; rhs) {
          if(lhs.ptr-&gt;mask &lt; rhs.ptr-&gt;mask)
              return true;
          if(lhs.ptr-&gt;mask &gt; rhs.ptr-&gt;mask)
              return false;
          if(lhs.ptr -&gt; a &lt; rhs.ptr-&gt;a)
              return true;
          if(lhs.ptr-&gt;a &gt; rhs.ptr-&gt;a)
              return false;
          return lhs.ptr-&gt;b &lt; rhs.ptr-&gt;b;
      }
  };
  
  vector&lt;likeatree *&gt; treeVector;
  deque&lt;bool&gt; stdDeque(3);
  vector&lt;vector&lt;bool&gt;&gt; boolMatrix{{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}};
  set&lt;weighted_pointer,ptrcomp&gt; stdSet;
  
  int main(){
      srand(time(NULL));
      likeatree * first_pointer = new likeatree{0,&amp;input[0],nullptr};
      likeatree * second_pointer = first_pointer;
      unique_ptr&lt;likeatree&gt; tmp(first_pointer);
      weighted_pointer wp;
      wp.weight = 1;
      wp.pointer = move(tmp);
      stdSet.insert(move(wp));
      // I'd like to do it inline(or more but with variables that end of scope here), but this don't work. (And i don't keep a copy of the pointer)
      // stdSet.insert(move(weighted_pointer{1,move(make_unique&lt;likeatree&gt;(*new likeatree{0,&amp;input[0],nullptr}))}));
      return 0;   
  }
  </code></pre>
  
  <p><em>Edit: Changed code with a single case of the problem</em> 
  <em>Edit: Solved. Missing a dereference when using make_unique.</em></p>