Construct a variadic template of unsigned int recursively
Posted
by
Vincent
on Stack Overflow
See other posts from Stack Overflow
or by Vincent
Published on 2012-09-05T14:41:53Z
Indexed on
2012/09/05
15:38 UTC
Read the original article
Hit count: 225
I need a tricky thing in a C++ 2011 code. Currently, I have a metafunction of this kind :
template<unsigned int N, unsigned int M>
static constexpr unsigned int myFunction()
This function can generate number based on N
and M
.
I would like to write a metafunction with input N
and M
, and that will recursively construct a variadic template by decrementing M
. For example, by calling this function with M = 3
, It will construct a variadic template called List
equal to :
List... = myFunction<N, 3>, myFunction<N, 2>, myFunction<N, 1>, myFunction<N, 0>
How to do that (if it is possible of course) ?
© Stack Overflow or respective owner