Why there is no specific type allowed in a variadic template pack?
template< typename T >
class Foo
{
public:
template< typename... Values >
void bar( Values... values )
{
}
template< T... values > <-- syntax error
void bar( T... values )
{
}
template< int... values > <-- syntax error
void bar( int... values )
{
}
};
Whats the rationale in not allowing this?
Are there proposals for this?
Note: alternatives would be
std::initializer_list< T >
without narrowing of types and the{ }
-brace-syntax- a (ugly) recursive trait that checks all types seperately: see here
It IS allowed, actually, you're just using it wrong.
T...
andint...
are non-type parameter packs and their elements are values, so you can't use them as type specifiers (and you can't deduce them from a function call).An example of correct usage:
or
Another example would be
std::integer_sequence
.