CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: size_t

  1. #1
    Join Date
    May 2008
    Location
    Montreal, Quebec, Canada
    Posts
    49

    size_t

    In a C++ book, it says the size_t "is guaranteed to be large enough to hold the size of an object in memory". Does that mean that the maximum size of size_t changes when u make large objects (like a bitset with a billion bits) or is its maximum size simply not defined and can be used to store any number?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: size_t

    It means that the size of size_t is implementation and platform dependent, but it nonetheless "is guaranteed to be large enough to hold the size of an object in memory", according to that book. As far as I can tell, the C and C++ standards only state that size_t is the type of the result of the sizeof operator and is guaranteed to be an unsigned integer type. I think that what that book states about such a guarantee merely follows from the relationship between sizeof and size_t.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: size_t

    Practically speaking, it'll probably be true that sizeof(size_t) == sizeof(void*). Which means 32 bits on 32-bit systems, 64 bits on 64-bit systems.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured