lundi 5 octobre 2020

Ambiguous call to overloaded function in variadic template function

I am using a variadic template function where the function parameters isn't the templated types.

I got a compilation error:

Error C2668 '_TailHelper': ambiguous call to overloaded function

Here it is the code snippet.

template <typename HEAD>
void _TailHelper(int) {
    std::cout << typeid(HEAD).name() << std::endl;
}

template <typename HEAD, typename ... TAILS>
void _TailHelper(int x) {
    _TailHelper<HEAD>(x);
    _TailHelper<TAILS...>(x);
}


int main(){
    _TailHelper<int,double>(2);
}

Aucun commentaire:

Enregistrer un commentaire