What is the right way to declare a multi-dimensional array that does not change size during runtime on the heap? (ideally in C++11, if there is some feature only available in C++14 (not C++17) I would love to hear about it too, but chances are it would not work for me)
I have by now looked through dozens of questions and answers about this topic but none seems to really answer it/some answers conflict with others.
The following solutions I have found and the problems they seem to have that make them non-viable (most of these taken from SO answers and their comments, examples all given with assuming a 3D-array as the target):
Normal [][][] array declared with new/declaring an array of pointers
Problem: Non-contiguous in memory, every individual array has its independent location in memorymultiple std::arrays/boost::arrays nested inside each other
Problem: Non-contiguous in memory, every individual array has its independent location in memoryMatrix
Problem: Just a container for std::array, same problems apply basicallymultiple std:vectors nested inside each other
Problem: Dynamic, pretty much all the other problems mentioned beforeDeclare as a single block with a pointer to a normal [] array, then go through the index by calculation during runtime with a function like GetIndex(array,x,y,z)
Problem: This seems to tick all points, but this solution seems less than ideal because of the significant CPU-overhead this seems to introduce when you need to access/change the elements often
Little bit unrelated to that, I have also had some issues with these solutions if they were in classes and I had to access their values from the outside with the . operator, so I would be even more grateful if someone could tell the correct solution with an example of both correct declaration and correct access of the heap-allocated multidimensional-array as a class-member.