• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <string_view>

    std::basic_string_view::remove_prefix

    constexpr void remove_prefix(size_type n);
    

    概要

    先頭のN文字を削除する。

    要件

    効果

    メンバ変数として、参照する文字配列へのポインタをconst CharT* data_、文字数をsize_type size_があるものとして、以下と等価:

    data_ += n;
    size_ -= n;
    

    #include <iostream>
    #include <string_view>
    
    int main()
    {
      std::string_view sv = "This is a pen";
    
      sv.remove_prefix(5); // 先頭5文字 "This " を削除
      std::cout << '[' << sv << ']' << std::endl;
    }
    

    出力

    [is a pen]
    

    バージョン

    言語

    • C++17

    処理系