samedi 26 mars 2016

Variadic template constructor priority

Given the following simple struct

template <typename T>
struct A
{
   A(T a) {}

   template <typename ... Ts>
   A(T a, Ts ... more) {}
};

int main()
{
   A<int> a(1);
}

What is the guarantee that A(T a) will be called instead of the variadic template constructor, and why?

Aucun commentaire:

Enregistrer un commentaire