// 报错信息转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