mercredi 5 septembre 2018

Varadic Templates not compiling MSVC compiler?

Trying to compile the following code snippet: This code is clearly using C++11 feature and been described in The C++ Programming Language book §3.4.4

template<typename T>
void g(T x)
{
    std::cout << x << " ";
}

template<typename T, typename... tail>
void f(T head, Tail... tail) {
    g(head); // do something to head
    f(tail...); // tr y again with tail
}

int main()
{
    f(1, "Lol", 5);
    getchar();
}

VS17 output :

C2672 'f': no matching overloaded function found Line:21 'void f(T,Tail...)': expects 2 arguments - 0 provided Line:19

any ideas ?

Aucun commentaire:

Enregistrer un commentaire