Getting the size_type of a container

I am trying to clear warnings in old code.
I have lots of for loops that take an int to browse vectors, so i get sign mismatch warnings.
I know that i can use
std::vector<MyType>::size_type
, but is there a shorter (but clean) way, particularly one not requiring the type contained in the container? I'm guessing size_type will always be the same regardless of the contained type, so there should be a common typename available right?
Try size_t.
Using the size_type is the best solution. You could use a shorthand version:

#define SIZE_TYPE(T) std::vector<T>::size_type

But just so you know, I would change to iterators instead. But that's just me.
Last edited on
Topic archived. No new replies allowed.