I would like to understand if the following is expected behavior that variadic templates have a lower precedence while matching arguments to template parameters vs. fixed number of parameters? Or is this a violation of the ODR rule. Used gcc 10.2.1
for this example.
template <typename T>
void func(T x) {
std::cout << "one";
}
template <typename ...T>
void func(T... x) {
std::cout << "two";
}
int main()
{
func(1); // prints "one"
}
Aucun commentaire:
Enregistrer un commentaire