title: optional virtual function in template hierarchy depending on parameter
body: <p>I have a template hierarchy, and I want it to have <code>clone()</code> function depending on whether template type is copy-constructible. As a first step I want to begin with additional parameter <code>bool Clonable</code>:</p>
  
  <pre><code>template&lt;class T, bool Clonable&gt;
  class Base {
    T t;
    void foo();
    virtual void bar();
    virtual unique_ptr&lt;Base&gt; clone() const = 0; //should be only for Clonable=true
  };
  
  template&lt;class T, bool Clonable&gt;
  class Derived : public Base&lt;T, Clonable&gt; {
    virtual void bar() override;
    virtual unique_ptr&lt;Base&gt; clone() const override; ////should be only for Clonable=true
  };
  </code></pre>
  
  <p>Unfortunately, instantiation of virtual functions does not depend on whether they are called or not. So I suppose that I should go with partial specialization. However, straightforward way leads to very much of code duplication. Could anyone recommend the way to achieve this with minimum code duplication?</p>