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

  1. リファレンス
  2. stack
  3. stack
  4. pop

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

履歴 編集

function
<stack>

std::stack::pop

void pop();           // (1) C++98
constexpr void pop(); // (1) C++26

概要

スタックトップ(コンテナの末尾側)の要素を削除する。内部でスタックを実装するコンテナオブジェクトのpop_back()メンバ関数が呼び出される。

効果

c.pop_back();

戻り値

なし。

計算量

Container::pop_back()と同じ。

例

#include <iostream>
#include <stack>

int main()
{
  std::stack<int> st;

  for (int i = 0; i < 5; ++i)
    st.push(i);

  std::cout << "Popping out elements...";
  while (!st.empty())
  {
     std::cout << " " << st.top();
     st.pop();
  }
  std::cout << std::endl;

  return 0;
}

出力

Popping out elements... 4 3 2 1 0 

実装例

void pop() { c.pop_back(); }

参照

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