D
Denis Remezov
Grumble said:What is the difference between size_t and vector<T>::size_type?
Are they ever a different type or a different size?
Why should one type the latter when the former is shorter?
What about the size_type type in other STL classes?
vector<T>::size_type is implementation-defined. The same holds for the
other standard containers. Generally, you cannot rely on it being size_t.
I've seen it defined (most commonly) as
typedef size_t size_type;
as well as
typedef _Allocator::size_type size_type;
where _Allocator was the container's allocator template parameter.
In the latter case you could actually end up getting it defined differently from
size_t (though the standard allocator defines size_type as size_t, there is no such
requirement for custom allocators).
I think you are better off using generic definitions (such as Container::size_type)
in generic code anyway, it makes it more generic (sorry for the wording).
Denis