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

履歴 編集

function
<deque>

std::deque::back

reference back();
const_reference back() const;

概要

末尾要素への参照を取得する

戻り値

末尾要素への参照

計算量

定数時間

備考

コンテナが空の状態でこの関数が呼ばれた場合、動作は未規定

#include <iostream>
#include <deque>

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

  // 末尾要素を取得する
  int& x = c.back();
  std::cout << x << std::endl;
}

出力

3

関連項目

名前 説明
front 先頭要素への参照を取得する
push_back 末尾に要素を追加する
pop_back 末尾要素を削除する