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::pop_back - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string
  3. basic_string
  4. pop_back

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

履歴 編集

function
<string>

std::basic_string::pop_back(C++11)

void pop_back();           // (1) C++11
constexpr void pop_back(); // (1) C++20

概要

末尾の1要素を削除する。

堅牢化された事前条件

!empty()

効果

erase(size() - 1, 1)

例外

投げない

例

#include <iostream>
#include <string>

int main()
{
  std::string s = "helloo";

  // 末尾の`o`を1つ削除する
  s.pop_back();

  std::cout << s << std::endl;
}

出力

hello

バージョン

言語

  • C++11

処理系

  • Clang: 3.0 ✅
  • GCC: 4.7.3 ✅
  • Visual C++: ?

参照

  • LWG Issue 534. Missing basic_string members
  • P0980R1 Making std::string constexpr
  • 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.