0
点赞
收藏
分享

微信扫一扫

c++find进行字符串匹配(C++从字符串里查找字符串)


// 报错信息转string
string error_info = e.what();
// 判断是否包含"CUDA out of memory"字符串
std::string::size_type idx = error_info.find("CUDA out of memory");
// 标志位
bool contain = idx != std::string::npos;
// 注册回调给上层
if (contain) {
return -1;
}

std::string::npos

作为返回值,它通常用于表示没有匹配项
就是异常值,溢出值:示例:18446744073709551615


举报

相关推荐

0 条评论