std::string::npos 常量解析
1、std::string::npos
std::string::npos
表示的是一个size_type
类型的常量,其值等于size_type
类型可以表示的最大值。
2、应用
std::string::find_first_not_of()
函数
函数定义:
size_t find_first_not_of (const string& str, size_t pos = 0) const noexcept;
size_t find_first_not_of (const char* s, size_t pos = 0) const;
size_t find_first_not_of (const char* s, size_t pos, size_t n) const;
size_t find_first_not_of (char c, size_t pos = 0) const noexcept;
在字符串中搜索与其参数中指定的任何字符都不匹配的第一个字符位置。
返回值: 不匹配的第一个字符的下标;如果没找到这样的字符,则返回 string::npos
。