Re: size_t and size_type

From: Leor Zolman (leor_at_bdsoft.com)
Date: 04/01/04


Date: Thu, 01 Apr 2004 15:55:15 GMT

On Thu, 01 Apr 2004 16:17:54 +0200, Grumble <invalid@kma.eu.org> wrote:

>What is the difference between size_t and vector<T>::size_type?

This should really be in the FAQ.

Bottom line: /probably/ none. The Standard explicitly allows container
implementors to assume that the allocators they're handed (from which the
size_type typedef may be propagated to the clients of the container,
although I have library implementations that just hard-wire size_t for the
container typedefs) define size_type as size_t. Extensions are also
permitted (see 20.1.5/4).

>
>Are they ever a different type or a different size?

If there are any such implementations, I don't know about them yet.

>
>Why should one type the latter when the former is shorter?

Either they were thinking ahead to some scenario when containers' memory
would come from some heap with totally different rules of memory management
that needed its own unique size_type, or else this is just an artifact of
the Intel segmented architecture memory-model that influenced the creation
of allocators in the first place. Who knows...

>
>What about the size_type type in other STL classes?

Same deal, AFAIK.
        -leor

-- 
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix  
C++ users: Download BD Software's free STL Error Message Decryptor at:
   www.bdsoft.com/tools/stlfilt.html


Relevant Pages

  • Re: STL Slow - VS2005
    ... will give slower node reuse but heap memory use will be minimal as it is ... Instead they measure the default choice of allocators that comes ... to inform the library designers what their intention is with a container. ... don depend on the choice of growth factor for vector, string. ...
    (microsoft.public.vc.stl)
  • Re: Finding the instance reference of an object [long and probably boring]
    ...  Being in a container isn't necessary, ... No, you forgot about cyclically-linked garbage, which Python ... implementations are allowed to, but not required to, collect. ...
    (comp.lang.python)
  • [-mm PATCH 10/10] Memory controller add documentation
    ... Differentiate between RSS and Page Cache - Paul Menage ... The infrastructure allows easy addition of other types of memory to control ... +c. Provides *zero overhead* for non memory controller users ... a container on hitting a limit, ...
    (Linux-Kernel)
  • Re: [ckrm-tech] [patch00/05]: Containers(V2)- Introduction
    ... I finally looked into your memory controller patches. ... Current cpuset feature in Linux kernel ... We use the term container to indicate a structure against which we track ... changes in kernel are minimized so as this support can ...
    (Linux-Kernel)
  • Re: Block based virtual harddisk library
    ... > to the virtual disk is block based. ... > actual file (container) on disk. ... > and trie structures contain extra data for each entry, memory can ... So on each new block allocation in the container ...
    (comp.programming)