I was wondering if I could have parameter packs consisting of a single, explicitly specified, type. For example, something like this:
#include
You might specify the type you want to show:
#include
template
void show_type() {}
template
void show_type(const T& x, Rest... rest)
{
std::cout << x << std::endl;
show_type(rest...);
}
template
void foo(int x, Args... args)
{
show_type(x, args...);
}
struct X { };
std::ostream& operator<<(std::ostream& o, X)
{
o << "x";
return o;
}
int main()
{
foo(1, 2, 3);
foo(1, 2, 3.0); // Implicit conversion
// or just
show_type(1, 2, 3);
foo(1, 2, X()); // Fails to compile
}