std::experimental::basic_string_view<CharT,Traits>::remove_prefix
來自 cppreference.com
< cpp | experimental | basic string view
constexpr void remove_prefix(size_type n); |
(庫基礎 TS) | |
將檢視的起始位置向前移動 n
個字元。
如果 n > size(),則行為未定義。
目錄 |
[編輯] 引數
n | - | 從檢視起始位置移除的字元數 |
[編輯] 返回值
(無)
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#include <iostream> #include <experimental/string_view> int main() { std::string str = " trim me"; std::experimental::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'
[編輯] 參閱
通過後移其末尾位置來收縮檢視 (公共成員函式) |