all compilers hands on agree fine:
template <typename check, typename... t> auto foo(check, t...) -> void; template <typename... t> auto foo(int, t...) -> void; int main() { foo(7, ""); }
however, following code (with leading template parameter cannot deduced function parameters) ambiguous according gcc:
template <typename x, typename check, typename... t> auto bar(check, t...) -> void; template <typename x, typename... t> auto bar(int, t...) -> void; int main() { bar<void>(7, ""); // ambiguous according gcc bar<void>(7); // fine }
on other hand, clang, msvc , icc quite happy this.
which compiler right?
references respective sections of standard preferred.
this core issue 200.
the description of how partial ordering of template functions determined in 14.5.6.2 [temp.func.order] paragraphs 3-5 not make provision nondeduced template parameters. example, function call in following code ambiguous, though 1 template "obviously" more specialized other:
template <class t> t f(int); template <class t, class u> t f(u); void g() { f<int>(1); }
the reason neither function parameter list allows template parameter
t
deduced; both deductions fail, neither template considered more specialized other , function call ambiguous.
the resolution of core issue 214, 1 reduced to, introduced [temp.deduct.partial]/11:
in cases, template parameters must have values in order deduction succeed, but partial ordering purposes template parameter may remain without value provided not used in types being used partial ordering.
apparently gcc's implementation of wording buggy once packs come play.
Comments
Post a Comment