|
BDE 4.39.x Production Release
|
#include <bslstl_stack.h>
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.
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.See bslstl_stack
Public Types | |
| typedef CONTAINER::value_type | value_type |
| typedef CONTAINER::reference | reference |
| typedef CONTAINER::const_reference | const_reference |
| typedef CONTAINER::size_type | size_type |
| typedef CONTAINER | container_type |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION_IF (stack, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< container_type >::value) | |
| stack () | |
| stack (const stack &original) | |
| stack (BloombergLP::bslmf::MovableRef< stack > original) | |
| stack (const CONTAINER &container) | |
| stack (BloombergLP::bslmf::MovableRef< CONTAINER > container) | |
| template<class ALLOCATOR > | |
| stack (const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class ALLOCATOR > | |
| stack (const CONTAINER &container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class ALLOCATOR > | |
| stack (const stack &original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class ALLOCATOR > | |
| stack (BloombergLP::bslmf::MovableRef< CONTAINER > container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class ALLOCATOR > | |
| stack (BloombergLP::bslmf::MovableRef< stack > original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class INPUT_ITER > | |
| stack (INPUT_ITER first, INPUT_ITER last) | |
| template<class INPUT_ITER , class ALLOCATOR > | |
| stack (INPUT_ITER first, INPUT_ITER last, const ALLOCATOR &allocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0) | |
| template<class t_RANGE > | |
| stack (from_range_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range) | |
| template<class t_RANGE , class t_ALLOCATOR > | |
| stack (from_range_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range, const t_ALLOCATOR &allocator, typename enable_if< bsl::uses_allocator< CONTAINER, t_ALLOCATOR >::value, t_ALLOCATOR >::type *=0) | |
| stack & | operator= (const stack &rhs) |
| stack & | operator= (BloombergLP::bslmf::MovableRef< stack > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false) |
| template<class... Args> | |
| reference | emplace (Args &&... args) |
| void | pop () |
| void | push (const value_type &value) |
| void | push (BloombergLP::bslmf::MovableRef< value_type > value) |
| template<class t_RANGE > | |
| void | push_range (BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range) |
| bool | empty () const |
| size_type | size () const |
| const_reference | top () const |
Public Attributes | |
| void swap(stack &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl reference | top () |
Protected Attributes | |
| container_type | c |
Friends | |
| template<class VAL , class CONT > | |
| bool | operator== (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| template<class VAL , class CONT > | |
| bool | operator!= (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| template<class VAL , class CONT > | |
| bool | operator< (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| template<class VAL , class CONT > | |
| bool | operator> (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| template<class VAL , class CONT > | |
| bool | operator<= (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| template<class VAL , class CONT > | |
| bool | operator>= (const stack< VAL, CONT > &, const stack< VAL, CONT > &) |
| typedef CONTAINER::const_reference bsl::stack< VALUE, CONTAINER >::const_reference |
| typedef CONTAINER bsl::stack< VALUE, CONTAINER >::container_type |
| typedef CONTAINER::reference bsl::stack< VALUE, CONTAINER >::reference |
| typedef CONTAINER::size_type bsl::stack< VALUE, CONTAINER >::size_type |
| typedef CONTAINER::value_type bsl::stack< VALUE, CONTAINER >::value_type |
|
inlineexplicit |
Create an empty stack. No allocator will be provided to the underlying container. That container's memory allocation will be provided by the default allocator of its type.
|
inline |
Create a stack having the value of the specified original. The currently installed default allocator is used to supply memory.
|
inline |
Create a stack having the value of the specified original by moving the contents of original to the new stack. The allocator associated with original is propagated for use in the new stack. original is left in a valid but unspecified state.
|
inlineexplicit |
Create a stack whose underlying container has the value of the specified container. The currently installed default allocator is used to supply memory.
|
inlineexplicit |
Create a stack whose underlying container has the value of the specified container (on entry) by moving the contents of container to the new stack. The allocator associated with container is propagated for use in the new stack. container is left in a valid but unspecified state.
|
inlineexplicit |
Create an empty stack, and use the specified basicAllocator to supply memory. If CONTAINER::allocator_type does not exist, this constructor may not be used.
|
inline |
Create a stack whose underlying container has the value of the specified container, and use the specified basicAllocator to supply memory. If CONTAINER::allocator_type does not exist, this constructor may not be used.
|
inline |
Create a stack having the value of the specified stack original and use the specified basicAllocator to supply memory. If CONTAINER::allocator_type does not exist, this constructor may not be used.
|
inline |
Create a stack whose underlying container has the value of the specified container (on entry) that uses basicAllocator to supply memory by using the allocator-extended move constructor of CONTAINER.container' is left in a valid but unspecified state. A bslma::Allocator * can be supplied for basicAllocator if the (template parameter) ALLOCATOR is bsl::allocator (the default). This method assumes that CONTAINER has a move constructor. If CONTAINER::allocator_type does not exist, this constructor may not be used.
|
inline |
Create a stack having the value of the specified original (on entry) that uses basicAllocator to supply memory by using the allocator-extended moved constructor of CONTAINER. original is left in a valid but unspecified state.
bslma::Allocator * can be supplied for basicAllocator if the (template parameter) ALLOCATOR is bsl::allocator (the default). Also note that this method assumes that CONTAINER has a move constructor. Also note that if CONTAINER::allocator_type does not exist, this constructor may not be used.
|
inline |
Create a stack passing the specified first and last to the constructor of the underlying container. Optionally specify an allocator used to supply memory. If allocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used.
|
inline |
|
inline |
Create a stack from the elements of the specifed range. Optionally specify an allocator used to supply memory. If allocator is not specified, a default-constructed object of the (template parameter) type t_ALLOCATOR is used.
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.
|
inline |
| bsl::stack< VALUE, CONTAINER >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | stack< VALUE, CONTAINER > | , |
| BloombergLP::bslma::UsesBslmaAllocator | , | ||
| BloombergLP::bslma::UsesBslmaAllocator< container_type >::value | |||
| ) |
|
inline |
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.
|
inline |
Return true if this stack contains no elements and false otherwise.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved to this stack using the move-assignment operator of CONTAINER. rhs is left in a valid but unspecified state, and if an exception is thrown, *this is left in a valid but unspecified state.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.
|
inline |
Remove the top element from this stack.
|
inline |
Push onto this stack a value_type object having the value of the specified value (on entry) by moving the contents of value to the new object on this stack. value is left in a valid but unspecified state.
|
inline |
Push the specified value onto the top of this stack.
| void bsl::stack< VALUE, CONTAINER >::push_range | ( | BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) | range | ) |
Push onto this stack the elements of the specified range.
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.
|
inline |
Return the number of elements contained in this stack.
| const_reference bsl::stack< VALUE, CONTAINER >::top | ( | ) | const |
Return a reference providing non-modifiable access to the element at the top of this stack.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
|
inline |
Exchange the value of this stack with the value of the specified other stack. Return a reference to the element at the top of this stack.