lam*_*fun 7 c++ portability stl
喜欢:
std::string<T>::size_typestd::list<T>::size_typestd::map<T>::size_typestd::vector<T>::size_type无论cplusplus.com和cppreference.com说,他们通常size_t,但他们真正的,明确保障的标准是size_t,除非使用自定义分配器?
对于STL容器 - 不.[container.requirements.general]中标准的表96列出了任何容器的容器要求X,非常清楚地说明了这一点:

但是,对于basic_string,size_type定义为
typedef typename allocator_traits<Allocator>::size_type size_type;
Run Code Online (Sandbox Code Playgroud)
这反过来将size_t用于std::allocator<..>为分配器.
另外,根据[array.overview]/3 std::array使用size_tas size_type.
| 归档时间: |
|
| 查看次数: |
515 次 |
| 最近记录: |