一次两个字符串算法

Two at a time string algorithms?

本文关键字:两个 字符串 算法 一次      更新时间:2023-10-16

是否有办法在单个命令中执行以下操作(为了避免测试)

if (mystring.find_first_not_of("X") != std::string::npos) {
    mystring.erase(0, mystring.find_first_not_of("X"));
}
mystring.erase(0, std::max(0, (std::make_signed<std::string::size_type>::type)
                           mystring.find_first_not_of('X')));

或不使用c++ 11:

mystring.erase(0, std::max(0, (int)mystring.find_first_not_of('X')));