When we want to be able to hold the size of something:

  • size_t is the type that can accommodate anything we could have in memory, so it’s always big enough.
  • As an optimization to our data structures, many should use unsigned instead of size_t, since on 64-bit systems this can make our objects much smaller, and there are many things that simply can’t go past 232.
  • When we are dealing with the size of a file on disk or something that can be dealt without mapping or loading the whole thing into memory all at once, we want to use a type like "unsigned long long" that can represent sizes larger than 232 even on 32-bit systems
Last modified 11 years ago Last modified on Jun 6, 2013 11:26:46 AM