std::basic_string_view::remove_prefix
constexpr void remove_prefix(size_type n); | | (since C++17) |
---|
将视图的开始向前移动n
人物。
如果n > size()
...
参数
n | - | number of characters to remove from the start of the view |
---|
返回值
%280%29
复杂性
常量。
例
二次
#include <iostream>
#include <string_view>
int main()
{
std::string str = " trim me";
std::string_view v = str;
v.remove_prefix(std::min(v.find_first_not_of(" "), v.size()));
std::cout << "String: '" << str << "'\n"
<< "View : '" << v << "'\n";
}
二次
产出:
二次
String: ' trim me'
View : 'trim me'
二次
另见
remove_suffix | shrinks the view by moving its end backward (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com