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

  1. リファレンス
  2. queue
  3. queue
  4. front

最終更新日時: 2026年08月25日 12時11分17秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<queue>

std::queue::front

value_type& front();           // (1) C++98
constexpr value_type& front(); // (1) C++26

const value_type& front() const;           // (2) C++98
constexpr const value_type& front() const; // (2) C++26

概要

queue の次の要素への参照を返す。

これは一番初めに queue に挿入された要素で、pop() メンバ関数で削除される要素である。

内部のコンテナの front() メンバ関数を呼ぶ。

戻り値

queue の最初の要素への参照。

value_type 型は内部のコンテナの値を表す型で、第1テンプレート引数の T と同じ型であるべきである。

例

#include <iostream>
#include <queue>

int main() {
  std::queue<int> que;

  // とりあえず3つ挿入
  que.push(10);
  que.push(20);
  que.push(30);

  // 1つ目を取り出し
  std::cout << que.front() << std::endl;
  que.pop();

  // 2つ目を取り出し
  std::cout << que.front() << std::endl;
  que.pop();

  return 0;
}

出力

10
20

実装例

value_type& front() { return c.front(); }
const value_type& front() const { return c.front(); }

参照

  • P3372R3 constexpr containers and adaptors
You are visitor 01402520 — 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.