Click to See Complete Forum and Search --> : size_t
chris_t_morin
August 11th, 2008, 10:18 PM
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
laserlight
August 11th, 2008, 10:34 PM
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.
Lindley
August 11th, 2008, 10:59 PM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.