简体   繁体   English

一次两个字符串算法?

[英]Two at a time string algorithms?

Is there a way to do the following in a single command (in order to avoid the test) 有没有一种方法可以在单个命令中执行以下操作(以避免测试)

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')));

Or without C++11: 还是没有C ++ 11:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM