title: template ctor type deduction does not work (no matching constructor for initialization of ...) with function<> argument
body: <p>I have this example (where I want to add a template overloaded constructor to class <code>C</code>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  #include &lt;string&gt;
  using namespace std;
  class Msg {
  public:
      void parse(const string &amp;s) {
          x = int(s[0]);
      }
      int x = 0;
  };
  class C {
  public:
      C(function&lt;void(const string &amp;)&gt; cb)
          : cb_(cb)
      {}
      template&lt;typename TMsg&gt;
      C(function&lt;void(const TMsg &amp;)&gt; cb)
          : C([&amp;, cb](const string &amp;s) {
                  TMsg m; m.parse(s); cb(m);
            })
      {}
      void test() {
          cb_("foo");
      }
      function&lt;void(const string &amp;)&gt; cb_;
  };
  void cb1(const string &amp;s) {
      cout &lt;&lt; "cb1: " &lt;&lt; s &lt;&lt; endl;
  }
  void cb2(const Msg &amp;msg) {
      cout &lt;&lt; "cb2: Msg{x=" &lt;&lt; msg.x &lt;&lt; "}" &lt;&lt; endl;
  }
  int main() {
      C c1(&amp;cb1), c2(&amp;cb2); c1.test(); c2.test();
      return 0;
  }
  </code></pre>
  
  <p>which gives this compiler error (clang++ 9.1):</p>
  
  <pre><code>test_func_arg_overload.cpp:37:17: error: no matching constructor for initialization of 'C'
      C c1(&amp;cb1), c2(&amp;cb2); c1.test(); c2.test();
                  ^  ~~~~
  test_func_arg_overload.cpp:12:7: note: candidate constructor (the implicit move constructor) not
        viable: no known conversion from 'void (*)(const Msg &amp;)' to 'C' for 1st argument
  class C {
        ^
  test_func_arg_overload.cpp:12:7: note: candidate constructor (the implicit copy constructor) not
        viable: no known conversion from 'void (*)(const Msg &amp;)' to 'const C' for 1st argument
  class C {
        ^
  test_func_arg_overload.cpp:14:5: note: candidate constructor not viable: no known conversion from
        'void (*)(const Msg &amp;)' to 'function&lt;void (const std::__1::string &amp;)&gt;' (aka 'function&lt;void (const
        basic_string&lt;char, char_traits&lt;char&gt;, allocator&lt;char&gt; &gt; &amp;)&gt;') for 1st argument
      C(function&lt;void(const string &amp;)&gt; cb)
      ^
  test_func_arg_overload.cpp:18:5: note: candidate template ignored: could not match 'function&lt;void
        (const type-parameter-0-0 &amp;)&gt;' against 'void (*)(const Msg &amp;)'
      C(function&lt;void(const TMsg &amp;)&gt; cb)
      ^
  1 error generated.
  </code></pre>
  
  <p>Is there a way to fix it other than making <code>C</code> a template class?</p>