標準ライブラリヘッダ <stack>
提供: cppreference.com
このヘッダはコンテナライブラリの一部です。
インクルード | ||
<initializer_list>(C++11) | ||
クラス | ||
スタック (LIFO データ構造) を提供するためにコンテナを適合させます (クラステンプレート) | ||
std::uses_allocator 型特性の特殊化 (関数テンプレート) | ||
関数 | ||
(C++20で削除)(C++20で削除)(C++20で削除)(C++20で削除)(C++20で削除)(C++20) |
stack 内の値を辞書的に比較します (関数テンプレート) | |
std::swap アルゴリズムの特殊化 (関数テンプレート) |
概要
#include <initializer_list> namespace std { template <class T, class Container = deque<T> > class stack; template <class T, class Container> bool operator==(const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> bool operator< (const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> bool operator> (const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y); template <class T, class Container> void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y))); template <class T, class Container, class Alloc> struct uses_allocator<stack<T, Container>, Alloc> : uses_allocator<Container, Alloc>::type { }; }
クラス std::stack
template <class T, class Container = std::deque<T> > class stack { public: typedef typename Container::value_type value_type; typedef typename Container::reference reference; typedef typename Container::const_reference const_reference; typedef typename Container::size_type size_type; typedef Container container_type; protected: Container c; public: explicit stack(const Container&); explicit stack(Container&& = Container()); template <class Alloc> explicit stack(const Alloc&); template <class Alloc> stack(const Container&, const Alloc&); template <class Alloc> stack(Container&&, const Alloc&); template <class Alloc> stack(const stack&, const Alloc&); template <class Alloc> stack(stack&&, const Alloc&); bool empty() const { return c.empty(); } size_type size() const { return c.size(); } reference top() { return c.back(); } const_reference top() const { return c.back(); } void push(const value_type& x) { c.push_back(x); } void push(value_type&& x) { c.push_back(std::move(x)); } template <class... Args> void emplace(Args&&... args) { c.emplace_back(std::forward<Args>(args)...); } void pop() { c.pop_back(); } void swap(stack& s) noexcept(noexcept(swap(c, s.c))) { using std::swap; swap(c, s.c); } };