title: Could not deduce template argument with std::basic_string
body: <p>The striped-down version of my problem:</p>
  
  <p>I want to merge these two functions:</p>
  
  <pre><code>void Bar(const std::string &amp;s);
  void Bar(const std::wstring &amp;s);
  </code></pre>
  
  <p>..into one templated function:</p>
  
  <pre><code>template &lt;class CharType&gt;
  void Foo(const std::basic_string&lt;CharType&gt; &amp;s);
  </code></pre>
  
  <p>And I thought I will be be able to call <code>Foo</code> like <code>(1)</code> and <code>(2)</code>, but to my surprise not even <code>(3)</code> works.</p>
  
  <pre><code>(1) Foo("my string");
  (2) Foo(std::string("my string"));
  (3) Foo(std::basic_string&lt;char&gt;("my string"));
  </code></pre>
  
  <p>I tried removing the <code>const</code> qualifier for parameter <code>s</code> and even dropping the  reference (<code>&amp;</code>), or calling with <code>lvalues</code> instead of <code>rvalues</code>, but all with the same result.</p>
  
  <p>The compiler (both gcc and VS - so I am pretty sure it's a standard compliant behaviour) can't deduce the template argument for <code>Foo</code>. Of course it works if I call <code>Foo</code> like <code>Foo&lt;char&gt;(...)</code>.</p>
  
  <p>So I would like to understand why this is, especially since the call <code>(3)</code> is a one-to-one type between the type of the calling parameter object and the function argument type.</p>
  
  <p>Secondly, I would like a workaround to this: to be able to use one templated function, and to be able to call it like <code>(1)</code> and <code>(2)</code>.</p>
  
  <p><strong>Edit</strong></p>
  
  <p><code>(2)</code> and <code>(3)</code> do work. I was declaring it wrong in my compiler (not like in my question):</p>
  
  <pre><code>template &lt;class CharType&gt;
      void Foo(const std::basic_string&lt;char&gt; &amp;s);
  </code></pre>
  
  <p>Sorry about that.</p>