Код ниже компилируется и работает отлично с MSVC 2013, но не clang ++ 3.6. Какой компилятор прав?Ошибка шаблона Variadic - MSVS2013 компилирует, clang-3.5 не
MSVC 2013 компилирует и выполняет код, печать 26,04:
#include <iostream>
template <typename T, typename ... U>
auto mul(T t, U ... u) -> decltype(t * mul(u ...))
{
return t * mul(u ...);
}
template <typename T>
T mul(T t) { return t; }
int main()
{
std::cout << mul(2., 3.1, 4.2) << std::endl;
}
Однако компиляция с лязгом ++ - 3.6 Урожайность ошибки:
$ clang++ test.cpp -stdlib=libc++ -Wall -Wextra -std=c++14
prog.cc:14:15: error: no matching function for call to 'mul'
std::cout << mul(2., 3.1, 4.2) << std::endl;
^~~
prog.cc:4:6: note: candidate template ignored: substitution failure [with T = double, U = <double, double>]: use of undeclared identifier 'mul'
auto mul(T t, U ... u) -> decltype(t * mul(u ...))
^ ~~~
prog.cc:10:3: note: candidate function template not viable: requires single argument 't', but 3 arguments were provided
T mul(T t) { return t; }
^
1 error generated.
Является ли заявление о мул не доступен определить возвращаемый typedecl?