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

前端 未结 7 1321
暗喜
暗喜 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:51

    I can't imagine that it wouldn't be safe on a 32-bit system, but 64-bit could be a problem (since ints remain 32 bit). To be safe, why not just declare your variable to be vector::size_type instead of unsigned int?

提交回复
热议问题