I can create a variadic template that accepts only pointers:
template<typename ... Types>
void F(Types *... args);
Or a variadic template that accepts only references:
template<typename ... Types>
void F(Types &... args);
How can I create a template that accepts either non-const reference or pointer?
E.g.
int a, b, c;
F(a, &b); // => F<int &, int *>
F(a, 3); // Error, 3 not pointer and cannot bind to non const-reference
Note: The reference version might seem ok because it can bind to pointer references but it is not since it will not bind to int * const
Aucun commentaire:
Enregistrer un commentaire