I need to set up a large number of std::vector in a lookup library. The all have the structure:
{N, N, ..., -N, -N}
I can do that with a number of templated functions:
template<int N>
static constexpr std::initializer_list<int> H2 = {N, -N};
template<int N>
static constexpr std::initializer_list<int> H4 = {N, N, -N -N};
...
from which I can simply do:
std::vector<int> v22 = H2<3>
std::vector<int> v35 = H3<5>
etc.
But would there be a way to include also the numbers 2, 4 etc. as a template parameter?
Aucun commentaire:
Enregistrer un commentaire