[#bsl-stack-05] = xref:bsl.adoc[bsl]::stack :relfileprefix: ../ :mrdocs: LIFO stack adapter over a container of `VALUE` elements. == Synopsis Declared in `<bslstl_stack.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class VALUE, class CONTAINER = xref:bsl/deque-0c.adoc[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 [cols="1,4"] |=== | Name| Description | xref:bsl/stack-05/const_reference.adoc[`const_reference`] | This `typedef` is an alias for `const_reference`. | xref:bsl/stack-05/container_type.adoc[`container_type`] | This `typedef` is an alias for `container_type`. | xref:bsl/stack-05/reference.adoc[`reference`] | This `typedef` is an alias for `reference`. | xref:bsl/stack-05/size_type.adoc[`size_type`] | This `typedef` is an alias for `size_type`. | xref:bsl/stack-05/value_type.adoc[`value_type`] | This `typedef` is an alias to `CONTAINER::value_type`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/stack-05/2constructor-010.adoc[`stack`] [.small]#[constructor]# | Constructors | xref:bsl/stack-05/operator_assign-0a.adoc[`operator=`] | Assignment operators | xref:bsl/stack-05/emplace.adoc[`emplace`] | Emplace a newly constructed `value_type` onto this stack. | xref:bsl/stack-05/empty.adoc[`empty`] | Return `true` if this stack contains no elements and `false` otherwise. | xref:bsl/stack-05/pop.adoc[`pop`] | Remove the top element from this stack. The behavior is undefined if this stack is empty. | xref:bsl/stack-05/push-08.adoc[`push`] | `push` overloads | xref:bsl/stack-05/push_range.adoc[`push_range`] | Push onto this stack the elements of the specified `range`. | xref:bsl/stack-05/size.adoc[`size`] | Return the number of elements contained in this stack. | xref:bsl/stack-05/swap.adoc[`swap`] | Exchange the value of this stack with the value of the specified `other` stack. | xref:bsl/stack-05/top-06.adoc[`top`] | `top` overloads | xref:bsl/stack-05/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<stack, UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator<container_type>::value>`] | Declare nested type traits for this type. |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:bsl/stack-05/c.adoc[`c`] | The `c` data member. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/stack-0f.adoc[`stack<TYPE>`] | Deduce the template parameter `VALUE` from the parameters supplied to the constructor of `stack`. | xref:bsl/stack-06f.adoc[`stack<TYPE, deque<TYPE, ALLOCATOR>>`] | Deduce the template parameters `VALUE` and `CONTAINER` from the parameters supplied to the constructor of `stack`. | xref:bsl/stack-06c.adoc[`stack<t_TYPE, deque<t_TYPE, t_ALLOCATOR>>`] | Deduce the template parameters `VALUE` and `ALLOCATOR` from the parameters supplied to the constructor of `stack`. | xref:bsl/stack-0c.adoc[`stack<CONTAINER::value_type, CONTAINER>`] | Deduce the template parameters `VALUE` and `CONTAINER` from the parameters supplied to the constructor of `stack`. | xref:bsl/stack-06b.adoc[`stack<CONTAINER::value_type, CONTAINER>`] | Deduce the template parameters `VALUE` and `CONTAINER` from the parameters supplied to the constructor of `stack`. | xref:bsl/stack-01.adoc[`stack<ranges::range_value_t<t_RANGE>>`] | Deduce the template parameter `VALUE` from the parameters supplied to the constructor of `stack`. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:bsl/operator_3way-03e.adoc[bsl::operator<=>]` | Return the three‐way comparison of the specified stacks; see the non‐member `operator<=>` in the `bsl` namespace. | `xref:bsl/operator_ge-0f.adoc[bsl::operator>=]` | Return whether the specified stacks compare lexicographically; see the non‐member `operator>=` in the `bsl` namespace. | `xref:bsl/operator_le-0b.adoc[bsl::operator<=]` | Return whether the specified stacks compare lexicographically; see the non‐member `operator<=` in the `bsl` namespace. | `xref:bsl/operator_gt-017.adoc[bsl::operator>]` | Return whether the specified stacks compare lexicographically; see the non‐member `operator>` in the `bsl` namespace. | `xref:bsl/operator_lt-08.adoc[bsl::operator<]` | Return whether the specified stacks compare lexicographically; see the non‐member `operator<` in the `bsl` namespace. | `xref:bsl/operator_not_eq-03.adoc[bsl::operator!=]` | Return whether two stacks have different values. | `xref:bsl/operator_eq-00.adoc[bsl::operator==]` | Return whether the specified stacks have the same value; see the non‐member `operator==` in the `bsl` namespace. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/operator_not_eq-079.adoc[`operator!=`] | Return whether the operands do not have the same value. | xref:bsl/operator_lt-0c.adoc[`operator<`] | Return whether `lhs` is lexicographically less than `rhs`. | xref:bsl/operator_le-0ec.adoc[`operator<=`] | Return whether `lhs` is lexicographically less than or equal to `rhs`. | xref:bsl/operator_3way-01d.adoc[`operator<=>`] | Return the three‐way comparison result of the specified `lhs` and `rhs` stacks by comparing their underlying containers. | xref:bsl/operator_eq-0e3.adoc[`operator==`] | Return whether the operands have the same value. | xref:bsl/operator_gt-00.adoc[`operator>`] | Return whether `lhs` is lexicographically greater than `rhs`. | xref:bsl/operator_ge-0b.adoc[`operator>=`] | Return whether `lhs` is lexicographically greater than or equal to `rhs`. | xref:bsl/swap-0cb.adoc[`swap`] | Swap the value of the specified `lhs` stack with the value of the specified `rhs` stack. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#