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

履歴 編集

function
<deque>

std::deque::front

reference front();
const_reference front() const;

概要

先頭要素への参照を取得する

戻り値

先頭要素への参照

計算量

定数時間

備考

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

#include <iostream>
#include <deque>

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

  // 先頭要素を取得する
  int& x = c.front();
  std::cout << x << std::endl;
}

出力

1

関連項目

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