Where can I look up the definition of size_type for vectors in the C++ STL?

前端 未结 7 1266
暗喜
暗喜 2021-01-12 21:15

It seems safe to cast the result of my vector\'s size() function to an unsigned int. How can I tell for sure, though? My documentation isn\'t cle

7条回答
  •  执笔经年
    2021-01-12 21:31

    The C++ standard only states that size_t is found in , which puts the identifiers in . My copy of Harbison & Steele places the minimum and maximum values for size_t in . That should give you a notion of how big your recipient variable needs to be for your platform.

    Your best bet is to stick with integer types that are large enough to hold a pointer on your platform. In C99, that'd be intptr_t and uintptr_t, also officially located in .

提交回复
热议问题