Any good new ways in C++11 to store, as members, "cloned" objects of other "hierarchy-classes"?
<p>We have a <code>Base</code> class and a <code>Derived</code> class that derives from <code>Base</code>.</p>

<p>In some other class, we want to have a member of type <code>shared_ptr&lt;Base&gt;</code>.</p>

<p>We cannot use the type <code>Base</code> directly because direct copying like that will rule out subclasses.</p>

<p>However, we still want to "copy" the <code>Base</code> (or subclass) object over upon construction, because we want to rule out the possibility of it being modified.</p>

<p>The classic way to deal with this is to put a virtual member function <code>clone()</code> into the <code>Base</code> class that every subclass of <code>Base</code> can then implement. Every <code>clone()</code> would then just return a "copy" of itself - for example, <code>Derived</code> would return <code>make_shared&lt;Derived&gt;(*this)</code>.</p>

<p>The problem with this approach is that this requires every new subclass of <code>Base</code> to implement this <code>clone()</code> function. The code in each <code>clone()</code> is rather boilerplate, and it seems somewhat unnatural to be repeating it all the time.</p>

<p>Any better ways to do this since C++11?</p>
