This is not a direct answer to your question, and I can only make a small contribution, because currently the answers relate to important points, but I want to draw your attention to the shortcomings of the heap design you have chosen.
A 3D vector rarely comes alone.
This, of course, is a compromise depending on the number of moves that you will need to make and the number of operations performed on the vectors.
If you use only individual vectors and do a lot of copy / move, you can stick to your heap design. But if you have several vectors (for example, in a vector or an array), and you want to work with them, I would recommend you not to do heap allocation if you are worried about performance.
std::vector<Vec3> a(20); class con_Vec3 { double x, y, z; }; std::vector<con_Vec3> b(20);
Vector a will support a continuous block of pointers for swimming, where the float values, in turn, will be somewhere else in memory, which means that your values ​​are actually scattered across memory. Vector b opposite will contain an adjacent block of 60 double s, all in one place.
The cost of moving such a std::vector will be the same for both cases (quasi-swap each), but if you copy them, the heap-based solution will be slower, since 21 selection and 20 copies will be performed, while in the solution without heap there is one distribution and 20 copies covering the entire vector.
source share