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

履歴 編集

function
<vector>

std::vector::pop_back

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

概要

末尾要素を削除する。

要件

empty() == falseであること。

戻り値

なし

例外

投げない

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  std::vector<int> v = {1, 2, 3};

  v.pop_back();

  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << std::endl;
  });
}

出力

1
2

参照