Destruction policy for `std::unique_ptr<Base>(ptr)` when I don't know how `ptr` was allocated?
<p>Another "modern C++" beginner question. I seem to have some misconception about how to properly use smart pointers / smart pointer destruction policies.</p>

<pre><code>struct Base {
    virtual Base* clone() const = 0;
    virtual ~Base() { }
};

void clone_and_use(const Base &amp;original) {
    auto clone = std::unique_ptr&lt;Base&gt;(original.clone());
    …  // do something with `clone`
}
</code></pre>

<p>As far as I can tell, when <code>clone</code> goes out of scope, the pointed-to memory will be <code>delete</code>d thanks to the <code>std::default_delete&lt;Base&gt;</code> destruction policy used by <code>std::unique_ptr&lt;Base&gt;</code> (which appears to be equivalent to <code>std::unique_ptr&lt;Base, std::default_delete&lt;Base&gt;&gt;</code>).</p>

<p>What if <code>original.clone()</code> returned a pointer to memory that was <em>not</em> allocated with <code>new</code>? Obviously the standard <code>std::default_delete&lt;Base&gt;</code> destruction policy would be inappropriate&mdash;<code>delete</code> should only be used together with <code>new</code>, but not with <code>new[]</code>, <code>malloc</code>, or anything else&mdash; and I should specify a different destruction policy when I create the <code>clone</code> smart pointer… but which one would I specify?</p>

<pre><code>    auto clone = std::unique_ptr&lt;Base, ?&gt;(original.clone());
    //                                 ^
</code></pre>

<p>I am guessing that I would have to extend <code>Base</code> such that I can simply ask any derived type to provide a destruction policy suitable for its <code>clone()</code> implementation, but I'm not exactly sure how I would do this.</p>

<p>Can someone show me how to:</p>

<ul>
<li>Define the <code>Base</code> interface such that it can support a <code>clone()</code> method without leading to leaked or incorrectly freed memory; and</li>
<li>How to properly work with smart pointer destruction policies (if they are necessary at all in this example)?</li>
</ul>