title: C++ using a template argument to resolve an overload
body: <p>I'm writing a wrapper template class which can wrap an arbitrary type and imbue it with some additional semantics, but I can't figure out how to get overload resolution to work properly. The issue arises when a conversion that would ordinarily be resolved by comparing ranks of competing conversion sequences, cannot be deduced by the compiler because the type in question is a template argument, rather than a function argument. For instance,</p>
  
  <pre><code>#include &lt;type_traits&gt;
  
  template &lt;typename T&gt; class Wrapper {
    T val;
  
  public:
    Wrapper() = default;
    template &lt;typename U&gt; Wrapper(Wrapper&lt;U&gt; x) : val(x.val) {}
  };
  
  void foo(Wrapper&lt;const char *&gt;) {}
  void foo(Wrapper&lt;bool&gt;) {}
  
  int main() {
    Wrapper&lt;char *&gt; cp;
    foo(cp);
  }
  </code></pre>
  
  <p>Here, the call to foo() is ambiguous. The desired behavior would be for the compiler to select <code>void foo(Wrapper&lt;const char *&gt;)</code>, as it would if <code>cp</code> were instead a <code>char *</code> and <code>foo</code> were instead <code>void foo(const char *)</code>. Is this possible?</p>
  
  <p><strong>EDIT</strong>: Thanks to everyone for the quick responses, but perhaps I should have been more clear. What I have given above is just an example. What I require is a general solution to the following question: given arbitrary types <code>T</code>, <code>U</code>, and <code>V</code>, suppose that C++'s built in overload resolution would prefer the conversion <code>T</code> -> <code>U</code> over <code>T</code> -> <code>V</code>. How can I then also ensure that C++ would prefer <code>Wrapper&lt;T&gt;</code> -> <code>Wrapper&lt;U&gt;</code> over <code>Wrapper&lt;T&gt;</code> -> <code>Wrapper&lt;V&gt;</code>?</p>
  
  <p>I made this clarification because it seemed that the answers were specifically addressing certain aspects of overload resolution, like cv-qualifiedness, whereas I really need a general solution.</p>