Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在单个命令中执行以下操作(以避免测试)
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')));