是否在std::string::erase(0)空字符串上定义了行为.因为cppreference说:
Removes count characters starting at index.
Run Code Online (Sandbox Code Playgroud)
但对于空字符串,索引0处的字符不存在.
似乎没问题,因为字符串的大小是0:
21.4.6.5 basic_string :: erase [string :: erase]
basic_string<charT,traits,Allocator>& erase(size_type pos = 0, size_type n = npos);1要求:
pos <= size()2投掷:out_of_range如果
pos > size().