Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr" rel="nofollow noreferrer"><code>std::unique_ptr</code></a> is not copyable, and any class that contains a <code>unique_ptr</code> is also not copyable, meaning <code>struct Tree</code> is not copyable. The argument to:</p> <pre><code>void Tree&lt;T&gt;::insert (Tree&lt;T&gt; child) { </code></pre> <p>is taking its argument by value. And:</p> <pre><code>template &lt;typename T&gt; void Tree&lt;T&gt;::insert (T arg) { Tree&lt;T&gt; child (arg); this-&gt;insert(child); } </code></pre> <p>requires the copy constructor. To correct this, make <code>struct Tree</code> moveable.</p> <hr> <p>Note <code>Tree</code> is <em>not</em> moveable (in contrast to <a href="https://stackoverflow.com/users/22985/batchyx">BatchyX</a>'s comment) due to the presence of:</p> <pre><code>~Tree () = default; </code></pre> <p>which is a <em>user-declared</em> destructor and from section <em>12.8 Copying and moving class objects</em> (point 9) of the c++11 standard (draft n3337):</p> <blockquote> <p>If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if</p> <ul> <li>X does not have a user-declared copy constructor,</li> <li>X does not have a user-declared copy assignment operator,</li> <li>X does not have a user-declared move assignment operator,</li> <li><strong>X does not have a user-declared destructor</strong>, and</li> <li>the move constructor would not be implicitly defined as deleted.</li> </ul> </blockquote> <p>(I was uncertain about the implicit generation of the move members and asked <a href="https://stackoverflow.com/questions/16897845/move-member-function-generation">this</a> question to be certain). To make it moveable either:</p> <ul> <li>remove the user-declared destructor, or</li> <li>define a move constructor and move assignment operator</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload