title: Template deduction with smart pointers
body: <p>My code looks like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  using namespace std;
  
  class myClass
  {
      int a;
  };
  
  template &lt;typename T, template&lt;typename ValueType&gt; class SmartPtr&gt; // (1)
  void myFunction(const void *pointer, SmartPtr&lt;T&gt;&amp; pointer2)
  {
      cout&lt;&lt;"with template"&lt;&lt;endl;
  }
  
  void myFunction(const void *pointer, unique_ptr&lt;myClass&gt;&amp; pointer2)
  {
      cout&lt;&lt;"without template "&lt;&lt; *(static_cast&lt;const int*&gt;(pointer))&lt;&lt;endl;
  }
  
  int main()
  {
      int* a = new int(5);
      unique_ptr&lt;myClass&gt; myUniquePtr(new myClass);
      shared_ptr&lt;myClass&gt; mySharedPtr(new myClass);
  
      myFunction(static_cast&lt;const void*&gt;(a), myUniquePtr); // (2)
      myFunction&lt;int, unique_ptr&lt;myClass&gt; &gt;(static_cast&lt;const void*&gt;(a), myUniquePtr); // (3)
      myFunction&lt;int, shared_ptr&lt;myClass&gt; &gt;(static_cast&lt;const void*&gt;(a), mySharedPtr); // (4)
  
      delete a;
  
      return 0;
  }
  </code></pre>
  
  <p>Calling 'myFunction' in (2) is OK - it calls 'myFunction' without template. But in (3) and (4) compiler can't deduce template arguments. It generates errors:</p>
  
  <p><code>no matching function for call to ‘myFunction(const void*, std::unique_ptr&lt;myClass&gt;&amp;)'</code> 
  and 
  <code>no matching function for call to ‘myFunction(const void*, std::shared_ptr&lt;myClass&gt;&amp;)'</code>
  respectively. </p>
  
  <p>The question is how to change the second argument of template in (1) so I can instantiate template with arbitrary smart pointer? I want to omit <code>ValueType</code> and use <code>T</code>.</p>