关于std::string::npos(字符串末尾位置)的使用:
一般作为查找匹配项
#include <iostream>
#include <string>
int main()
{
std::string str = "I love you";
size_t index = str.find('.');
if (index == std::string::npos)
{
//没有查到匹配项
std::cout << "This does not contain any period!" << std::endl;
std::cout << index << std::endl;
}
return 0;
}