I want to make a variadic template with exactly N arguments, where N is also a template parameter. For example,
template <int N, typename T[N]>
void function(T t[N]) {
// do stuff with t[0] through t[N-1]
}
(I realize the above is not valid syntax)
I know that one way to achieve this is to use a static_assert
on sizeof...(ArgsT)
where ArgsT
is a variadic template definition (i.e. template <typename ...ArgsT>
).
I am just wondering if there is a better way, not necessarily involving static_assert
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…