vendredi 2 octobre 2015

Multiple pack expansions inside class with fixed number of template arguments

Is this code well-formed? The declaration of the function template itself gives an error in both clang and gcc even though Ts could well be empty.

// error: too many template arguments for class template 'pair'
template<class I, class U, class... Ts>
void f(std::pair<I,U,Ts...>);

int main()
{
    f(std::pair<int,int>());
}

The function call gives this error in gcc which doesn't make sense. There is no conversion to int:

note: cannot convert 'std::pair<int, int>()' (type 'std::pair<int, int>') to type 'int'

Aucun commentaire:

Enregistrer un commentaire