Re: size_t and size_type
From: Denis Remezov (denis_remezovREMOVETHIS_at_yahoo.ca.removethis)
Date: 04/01/04
- Next message: Leor Zolman: "Re: C++: why 80 charachters??"
- Previous message: Leor Zolman: "Re: size_t and size_type"
- In reply to: Grumble: "size_t and size_type"
- Next in thread: John Harrison: "Re: size_t and size_type"
- Reply: John Harrison: "Re: size_t and size_type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 01 Apr 2004 11:25:09 +0000
Grumble wrote:
>
> 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?
>
> --
> Regards, Grumble
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
- Next message: Leor Zolman: "Re: C++: why 80 charachters??"
- Previous message: Leor Zolman: "Re: size_t and size_type"
- In reply to: Grumble: "size_t and size_type"
- Next in thread: John Harrison: "Re: size_t and size_type"
- Reply: John Harrison: "Re: size_t and size_type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]