c++ - Overload resolution produces ambiguous call when template parameters added -
in following code compiler can resolve call f() call f(int&, const char*) . the call g() , however, ambiguous. lists 4 overloads possible overload set. if remove , typename t2, std::size_t i template argument list array argument, , hard code them instead, there no ambiguity , compiler picks g(t&, const char*) . how adding 2 template arguments makes ambiguous? can see how, though decay , casting, resolve 1 of overloads, cannot figure out how adding template parameters introduces ambiguity. i have testing on clang 3.8 (unreleased) , vc++ 2015. #include <string> void f(int&, const char*){} void f(int&, char(&)[8]){} void f(int&, bool){} void f(int&, const std::string&){} template <typename t> void g(t&, bool){} template <typename t> void g(t&, const char*){} template <typename t> void g(t&, const std::string&){} template <typename t, typename t2, std::size_t i> void g(t&, t2(&)[i]){} ...