For a performance oriented library, we currently employ std::arrays, whose length are depending on the problem.
As a result, the whole code is templated with <int N1, int N2>, where N_1,N_2 are the unrelated length of the arrays being used, leading to long and memory intensive compilation, for probably little performance gain.
How can we replace in the most modern way these arrays, given that:
- Size of the array are known at run time
- These array might contain PODs and custom class alike
- We loop over these arrays a LOT
- Length of these arrays are between 0 and 5, so they are kind of small
- These arrays don't get copied around, and destroyed at the end of the code
- C++17
My first idea was to wrap in a struct a unique_ptr<T[]>, with T templated, equipped with all the arrays methods we use in the code, to minimise refactoring.
My questions are:
- What would be the drawback of my initial idea?
- Is there any better/more modern way to achieve that?