std::string::size_type index 是什么意思?

2025-12-18 06:50:42
推荐回答(3个)
回答1:

这种东西要学会自己找
实际上这就是个整型声明,可以把index赋给任何整型而不会报错误或警告。

在我的GNU G++实现中
basic_string.h有定义
typedef typename _Alloc::size_type size_type;

而 allocator.h中还有
typedef size_t size_type;

回答2:

index 是size_type类型啊

size_type是 string里定义的 可能是int类型的

string 是 std 名字空间里的 即标准空间

回答3:

std::string::size_type 一般情况下是unsigned int
只是C++应该一般用模板,所以size_type最后定~~
你可以当成unsigned int 就行了