[C++] how to check how much is allocated?
Is it stupid of me to avoid std::vector because code creating a std::vector of Engine::Vector (my mathematical kind of vector, used all over the place) could become hard to read?...
Quote:Original post by bluescrn
Is it stupid of me to avoid std::vector because code creating a std::vector of Engine::Vector (my mathematical kind of vector, used all over the place) could become hard to read?...
Well that can be an issue, but std::vector is too useful to avoid for that reason.
Besides most people name their mathematical vectors something along the line of vector2, vector3, vector4 etc, where the number describes how many components that vector class has.
Quote:Original post by bluescrn
Is it stupid of me to avoid std::vector because code creating a std::vector of Engine::Vector (my mathematical kind of vector, used all over the place) could become hard to read?...
This is what typedefs are for. Ex:
typedef std::vector<Engine::Vector> VectorArray;
Quote:Original post by fpsgamer
Besides most people name their mathematical vectors something along the line of vector2, vector3, vector4 etc, where the number describes how many components that vector class has.
Getting rather offtopic for this thread, but I did originally start out with a 'Vector4' class. Then realised that what I really wanted was a Vector3 with a 4th component for the few times it's needed (and for data alignment)
I didn't need to implement both a Vector3 and Vector4 class, as I've got no use for true 4D vectors (with full 4-component arithmetic) Most of the operations just operate on .xyz - so neither Vector3 or Vector4 seemed to be a good name for it... So it just became 'Vector'
(In the same way, I've just got 'Matrix', which is always 4x4, but has methods for 3x3 and 3x4 operations)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement