title: Enable Copy Constructor if function is found
body: <p>I have a RAII wrapper around a <code>Foo*</code> where <code>Foo</code> is a library.</p>
  
  <p>The class looks pretty much like this:</p>
  
  <pre><code>struct Handle{
    Foo* p;
    Handle(): p(foo_new()){}
    Handle(Handle&amp;&amp; f): p(std::exchange(f.p, nullptr)){}
    Handle(const Handle&amp; f){
      p = foo_clone(f.p);
    }
  };
  </code></pre>
  
  <p>Error handling and assignment operators omitted for brevity.</p>
  
  <p>The problem now is, that <code>foo_clone</code> is available in 1 library version, but not an earlier one and the wrapper should support both. There is no <code>*_VERSION</code> macro for me to check so I need to do it in C++ instead of the preprocessor.</p>
  
  <p>I though of something like:</p>
  
  <pre><code>template&lt;class T, decltype(foo_clone(std::declval&lt;T&gt;().p)) = nullptr&gt;
  Handle(const T&amp; f){...}
  </code></pre>
  
  <p>But this doesnt work: The defined move-ctor requires me to add a copy ctor verbatim as <code>Handle(const Handle&amp;)</code>, no template trickery seems to be allowed as otherwise the compiler considers the copy-ctor as implicitely deleted.</p>
  
  <p>What can I do?</p>