GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::basic_string_view::remove_prefix - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string_view
  3. basic_string_view
  4. remove_prefix

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<string_view>

std::basic_string_view::remove_prefix(C++17)

constexpr void remove_prefix(size_type n);

概要

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

堅牢化された事前条件

  • n <= size()であること

効果

メンバ変数として、参照する文字配列へのポインタを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

処理系

  • Clang: 4.0 ✅
  • GCC: 7.1 ✅
  • Visual C++: ??

参照

  • P3471R4 Standard library hardening
  • P3878R1 Standard library hardening should not use the 'observe' semantic
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.