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

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

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

履歴 編集

function
<queue>

std::priority_queue::top

const_reference top() const;           // (1) C++98
constexpr const_reference top() const; // (1) C++26

概要

次に処理する要素を取得する。

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

効果

return c.front();

戻り値

次に処理する要素への参照

例

#include <iostream>
#include <queue>

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

  que.push(3);
  que.push(1);
  que.push(4);

  while (!que.empty()) {
    const int& x = que.top();
    std::cout << x << std::endl;
    que.pop();
  }
}

出力

4
3
1

参照

  • 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.