Game Development Community

Vector.size() S32 or U32?

by Adam Johnston · in Torque Game Builder · 04/25/2006 (9:22 am) · 1 replies

Right now:
template<class T> inline S32 Vector<T>::size() const
{
   return (S32)mElementCount;
}
but:
U32 mElementCount;
I'm thinking if the cast U32 -> S32 is not dangerous if the vector is going to
storage a huge number of elements.
Any comments out there?

#1
04/25/2006 (11:26 am)
Size_t is used in STL and the C-runtime for array indexing and size. size_t is defined as an unsigned int. It's my opinion that Vector::size() needs to be changed to U32. Special attention should be paid to any new warnings that pop up because of this change as it could indicate a bug.