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

履歴 編集

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

処理系

参照