bsl::stack

LIFO stack adapter over a container of VALUE elements.

Synopsis

Declared in <bslstl_stack.h>

template<
    class VALUE,
    class CONTAINER = deque<VALUE>>
class stack;

Description

This class defines a container adapter which supports access primarily via push, pop, and top. This type can be based on a variety of other container types, including deque, vector, and list. This type is value-semantic if the supporting CONTAINER and VALUE are value-semantic.

Note that we never use VALUE in the implementation except in the default argument of CONTAINER. We use CONTAINER::value_type for everything, which means that if CONTAINER is specified, then VALUE is ignored.

Type Aliases

NameDescription
const_reference This typedef is an alias for const_reference.
container_type This typedef is an alias for container_type.
reference This typedef is an alias for reference.
size_type This typedef is an alias for size_type.
value_type This typedef is an alias to CONTAINER::value_type.

Member Functions

NameDescription
stack [constructor]Constructors
operator= Assignment operators
emplace Emplace a newly constructed value_type onto this stack.
empty Return true if this stack contains no elements and false otherwise.
pop Remove the top element from this stack. The behavior is undefined if this stack is empty.
push push overloads
push_range Push onto this stack the elements of the specified range.
size Return the number of elements contained in this stack.
swap Exchange the value of this stack with the value of the specified other stack.
top top overloads
operator BloombergLP::bslmf::NestedTraitDeclaration<stack, UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator<container_type>::value> Declare nested type traits for this type.

Protected Data Members

NameDescription
c The c data member.

Deduction Guides

NameDescription
stack<TYPE> Deduce the template parameter VALUE from the parameters supplied to the constructor of stack.
stack<TYPE, deque<TYPE, ALLOCATOR>> Deduce the template parameters VALUE and CONTAINER from the parameters supplied to the constructor of stack.
stack<t_TYPE, deque<t_TYPE, t_ALLOCATOR>> Deduce the template parameters VALUE and ALLOCATOR from the parameters supplied to the constructor of stack.
stack<CONTAINER::value_type, CONTAINER> Deduce the template parameters VALUE and CONTAINER from the parameters supplied to the constructor of stack.
stack<CONTAINER::value_type, CONTAINER> Deduce the template parameters VALUE and CONTAINER from the parameters supplied to the constructor of stack.
stack<ranges::range_value_t<t_RANGE>> Deduce the template parameter VALUE from the parameters supplied to the constructor of stack.

Friends

NameDescription
bsl::operator<=>Return the three-way comparison of the specified stacks; see the non-member operator<=> in the bsl namespace.
bsl::operator>=Return whether the specified stacks compare lexicographically; see the non-member operator>= in the bsl namespace.
bsl::operator<=Return whether the specified stacks compare lexicographically; see the non-member operator<= in the bsl namespace.
bsl::operator>Return whether the specified stacks compare lexicographically; see the non-member operator> in the bsl namespace.
bsl::operator<Return whether the specified stacks compare lexicographically; see the non-member operator< in the bsl namespace.
bsl::operator!=Return whether two stacks have different values.
bsl::operator==Return whether the specified stacks have the same value; see the non-member operator== in the bsl namespace.

Non-Member Functions

NameDescription
operator!=Return whether the operands do not have the same value.
operator<Return whether lhs is lexicographically less than rhs.
operator<=Return whether lhs is lexicographically less than or equal to rhs.
operator<=>Return the three-way comparison result of the specified lhs and rhs stacks by comparing their underlying containers.
operator==Return whether the operands have the same value.
operator>Return whether lhs is lexicographically greater than rhs.
operator>=Return whether lhs is lexicographically greater than or equal to rhs.
swapSwap the value of the specified lhs stack with the value of the specified rhs stack.