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.

Synopsis

Declared in <bslstl_stack.h>

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

Description

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

Name

Description

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

Name

Description

stack [constructor]

Constructors

operator=

Assignment operators

emplace

Push onto this stack a newly created value_type object constructed by forwarding get_allocator() (if required) and the specified (variable number of) args to the corresponding constructor of value_type. Return a reference providing modifiable access to the inserted element.

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. Note that range must meet the requirements of an input range and the values from range must have a type matching or convertible to (template parameter) VALUE.

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

Name

Description

c

The c data member.

Deduction Guides

Name

Description

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. This deduction guide does not participate unless the ALLOCATOR parameter meets the requirements for a standard allocator.

stack<t_TYPE, deque<t_TYPE, t_ALLOCATOR>>

Deduce the template parameters VALUE and ALLOCATOR from the parameters supplied to the constructor of stack. This deduction guide does not participate unless the t_ALLOCATOR parameter meets the requirements for a standard allocator.

stack<CONTAINER::value_type, CONTAINER>

Deduce the template parameters VALUE and CONTAINER from the parameters supplied to the constructor of stack. This deduction guide does not participate if the parameter meets the requirements for a standard allocator.

stack<CONTAINER::value_type, CONTAINER>

Deduce the template parameters VALUE and CONTAINER from the parameters supplied to the constructor of stack. This deduction guide does not participate unless the supplied allocator is convertible to the underlying container's allocator_type.

stack<ranges::range_value_t<t_RANGE>>

Deduce the template parameter VALUE from the parameters supplied to the constructor of stack.

Friends

Name

Description

bsl::operator<=>

Same as the related overload above for operator<=>.

bsl::operator>=

Same as the related overload above for operator>=.

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!=

Same as the related overload above for operator!=.

bsl::operator==

Same as the related overload above for operator==.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two stack objects lhs and rhs do not have the same value if they do not have the same number of elements, or some element in the ordered sequence of elements of lhs does not have the same value as the corresponding element in the ordered sequence of elements of rhs. This method requires that the (template parameter) type VALUE be equality‐comparable (see {Requirements on VALUE}).

operator<

Return true if the value of the specified lhs stack is lexicographically less than that of the specified rhs stack, and false otherwise. Given iterators i and j over the respective sequences [lhs.begin() .. lhs.end())] and [rhs.begin() .. rhs.end())], the value of stack lhs is lexicographically less than that of stack rhs if true == *i < *j for the first pair of corresponding iterator positions where *i < *j and *j < *i are not both false. If no such corresponding iterator position exists, the value of lhs is lexicographically less than that of rhs if lhs.size() < rhs.size(). This method requires that operator<, inducing a total order, be defined for value_type.

operator<=

Return true if the value of the specified lhs stack is lexicographically less than or equal to that of the specified rhs stack, and false otherwise. The value of stack lhs is lexicographically less than or equal to that of stack rhs if rhs is not lexicographically less than lhs (see operator<). This method requires that operator<, inducing a total order, be defined for value_type. Note that this operator returns !(rhs < lhs).

operator<=>

Same as the related overload above for operator<=>.

operator==

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two stack objects lhs and rhs have the same value if they have the same number of elements, and each element in the ordered sequence of elements of lhs has the same value as the corresponding element in the ordered sequence of elements of rhs. This method requires that the (template parameter) type VALUE be equality‐comparable (see {Requirements on VALUE}).

operator>

Return true if the value of the specified lhs stack is lexicographically greater than that of the specified rhs stack, and false otherwise. The value of stack lhs is lexicographically greater than that of stack rhs if rhs is lexicographically less than lhs (see operator<). This method requires that operator<, inducing a total order, be defined for value_type. Note that this operator returns rhs < lhs.

operator>=

Return true if the value of the specified lhs stack is lexicographically greater than or equal to that of the specified rhs stack, and false otherwise. The value of stack lhs is lexicographically greater than or equal to that of stack rhs if lhs is not lexicographically less than rhs (see operator<). This method requires that operator<, inducing a total order, be defined for value_type. Note that this operator returns !(lhs < rhs).

swap

Swap the value of the specified lhs stack with the value of the specified rhs stack.

Created with MrDocs