Stack#

Source file#

ChaiGO container/adapter/stack

Interface#

template<ContainerElement T, SequenceContainer Container = Deque<T>>
class Stack#

a LIFO (last-in, first-out) data structure.

Any sequence container supporting operations back(), push_back() and pop_back() can be used to instantiate stack. In particular, vector, list and deque can be used.

Difference

Allocator is not required as container’s template parameter.

模板参数
  • T – Type of element. Required to be a complete type.

  • Container – Type of the underlying container to use to store the elements.

Public Types

using value_type = typename Container::value_type#
using reference = typename Container::reference#
using const_reference = typename Container::const_reference#
using size_type = typename Container::size_type#
using container_type = Container#

Public Functions

inline constexpr Stack() noexcept#
inline constexpr Stack(const Container &container) noexcept#
inline constexpr Stack(Container &&container) noexcept#
inline constexpr Stack(const Stack &other) noexcept#
inline constexpr Stack(Stack &&other) noexcept#
template<std::input_iterator InputIt>
inline constexpr Stack(InputIt first, InputIt last) noexcept#
inline constexpr Stack(std::initializer_list<T> ilist) noexcept#
~Stack() = default#
inline constexpr Stack &operator=(const Stack &other) noexcept#
inline constexpr Stack &operator=(Stack &&other) noexcept#
inline constexpr bool empty() const noexcept#
inline constexpr size_type size() const noexcept#
inline constexpr reference top() noexcept#
inline constexpr const_reference top() const noexcept#
inline constexpr void push(const value_type &x) noexcept#
inline constexpr void push(value_type &&x) noexcept#
template<class ...Args>
inline constexpr decltype(auto) emplace(Args&&... args) noexcept#
inline constexpr void pop()#
inline constexpr void swap(Stack &s) noexcept(std::is_nothrow_swappable_v<Container>)#