Is it possible to constrain the type of arguments in a variadic constructor?
I want to be able to express
X x1(1,3,4);
X x2(3,4,5);
// syntax error: identifier 'Args'
class X {
template<int ... Args> X(Args...)
{
}
};
// this works but allows other types than int
class Y {
template<typename ... Args> Y(Args...)
{
}
};
edit to clarify intent:
What I want to achieve is to store data passed into a constructor (constants known at compile time) into a static array.
so there are some other
template<int ...values>
struct Z
{
static int data[sizeof...(values)];
};
template<int ... values>
int Z<values...>::data[sizeof...(values)] = {values...};
and in the constructor of X I would like to use Z like this:
class X {
template<int ... Args> X(Args...)
{
Z<Args...>::data // do stuff with data
}
};
Is that possible, our do I have to use integer_sequence?