jeudi 25 octobre 2018

More concise way to declare high dimensional vector

I don't like how for example a 3 dimensional vector is called this way:

std::vector<std::vector<std::vector<value_type>>>

Not to mention if I would like to have 4 dimensional or even higher.

Is there any way to use perhaps template metaprogramming or some technique to be able to declare high dimension vector with higher readability?

For example to be able to declare an high dimensional vector like this (just an example):

t_vector<5, {10, 2, 2, 2, 2}, int> a;

and get a with capacity of [10][2][2][2][2].

Is it possible to do something like this? Or why if not?

Aucun commentaire:

Enregistrer un commentaire