名前空間
変種
操作

std::basic_string_view<CharT,Traits>::remove_prefix

提供: cppreference.com
 
 
 
 
constexpr void remove_prefix(size_type n);
(C++17以上)

ビューの開始位置を n 文字だけ前進させます。

n > size() の場合、動作は未定義です。

目次

[編集] 引数

n - ビューの先頭から削除する文字数

[編集] 戻り値

(なし)

[編集] 計算量

一定。

[編集]

#include <iostream>
#include <algorithm>
#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'

[編集] 関連項目

終点を後退させるとこによってビューを縮小させます
(パブリックメンバ関数) [edit]