Like:
std::string<T>::size_type
std::list<T>::size_type
std::map<T>::size_type
std::vector<T>::size_type
- etc.
Both cplusplus.com http://www.cplusplus.com/reference/vector/vector and cppreference.com http://en.cppreference.com/w/cpp/container/vector说他们通常是size_t
,但它们真的、明确吗?保证按标准是size_t
除非使用自定义分配器?
对于 STL 容器 - 不。 [container.requirements.general] 中标准的表 96,列出了任何容器的容器要求X
,解释得很清楚:
然而,对于basic_string
, size_type
定义为
typedef typename allocator_traits<Allocator>::size_type size_type;
这反过来将是size_t
for std::allocator<..>
作为分配器。
Also, std::array
uses size_t
as size_type
,根据 [array.overview]/3。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)