jeudi 2 avril 2015

deduce two different known type variables in different parameter packs within a variadic function

I have the following code:



template <typename... Type1, typename... Type2>
void foo(const Type1&&... t1, Type2&&... t2)
{
int len = sizeof...(Type1);
cout << len << endl;
int len1 = sizeof...(Type2);
cout << len1 << endl;
}

int main()
{
foo(1, 2, 4.5, 5.5);

return 0;
}


calling foo() deduces Type1 as empty and Type2 as {int, int, double, double}, while what I would like to have is Type1 as {int, int} and Type2 as {double, double}.Is that possible without involving std::tuple and just calling the foo() function as I have it in the above code?


Aucun commentaire:

Enregistrer un commentaire