Quick Links:

bal | bbl | bdl | bsl

Classes | Typedefs | Functions | Variables | Friends

Component bslstl_stack
[Package bslstl]

Provide an STL-compliant stack class. More...

Classes

class  bsl::stack< VALUE, CONTAINER >

Typedefs

typedef CONTAINER::value_type bsl::stack::value_type
typedef CONTAINER::reference bsl::stack::reference
typedef CONTAINER::const_reference bsl::stack::const_reference
typedef CONTAINER::size_type bsl::stack::size_type
typedef CONTAINER bsl::stack::container_type

Functions

 bsl::stack::BSLMF_NESTED_TRAIT_DECLARATION_IF (stack, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< container_type >::value)
 bsl::stack::stack ()
 bsl::stack::stack (const stack &original)
 bsl::stack::stack (BloombergLP::bslmf::MovableRef< stack > original)
 bsl::stack::stack (const CONTAINER &container)
 bsl::stack::stack (BloombergLP::bslmf::MovableRef< CONTAINER > container)
template<class ALLOCATOR >
 bsl::stack::stack (const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::stack::stack (const CONTAINER &container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::stack::stack (const stack &original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::stack::stack (BloombergLP::bslmf::MovableRef< CONTAINER > container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::stack::stack (BloombergLP::bslmf::MovableRef< stack > original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
stack & bsl::stack::operator= (const stack &rhs)
stack & bsl::stack::operator= (BloombergLP::bslmf::MovableRef< stack > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false)
template<class... Args>
reference bsl::stack::emplace (Args &&...args)
void bsl::stack::pop ()
void bsl::stack::push (const value_type &value)
void bsl::stack::push (BloombergLP::bslmf::MovableRef< value_type > value)
bool bsl::stack::empty () const
size_type bsl::stack::size () const
const_reference bsl::stack::top () const
template<class VALUE , class CONTAINER >
bool bsl::operator== (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
bool bsl::operator!= (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
bool bsl::operator< (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
bool bsl::operator> (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
bool bsl::operator<= (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
bool bsl::operator>= (const stack< VALUE, CONTAINER > &lhs, const stack< VALUE, CONTAINER > &rhs)
template<class VALUE , class CONTAINER >
void bsl::swap (stack< VALUE, CONTAINER > &lhs, stack< VALUE, CONTAINER > &rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false)

Variables

container_type bsl::stack::c
void swap(stack &other)
BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl
reference 
bsl::stack::top ()

Friends

template<class VAL , class CONT >
bool bsl::stack::operator== (const stack< VAL, CONT > &, const stack< VAL, CONT > &)
template<class VAL , class CONT >
bool bsl::stack::operator!= (const stack< VAL, CONT > &, const stack< VAL, CONT > &)
template<class VAL , class CONT >
bool bsl::stack::operator< (const stack< VAL, CONT > &, const stack< VAL, CONT > &)
template<class VAL , class CONT >
bool bsl::stack::operator> (const stack< VAL, CONT > &, const stack< VAL, CONT > &)
template<class VAL , class CONT >
bool bsl::stack::operator<= (const stack< VAL, CONT > &, const stack< VAL, CONT > &)
template<class VAL , class CONT >
bool bsl::stack::operator>= (const stack< VAL, CONT > &, const stack< VAL, CONT > &)

Detailed Description

Outline
Purpose:
Provide an STL-compliant stack class.
Classes:
bsl::stack STL-compliant stack template
Canonical Header:
bsl_stack.h
See also:
Component bslstl_deque, Component bslstl_vector, Component bslstl_list, Component bslstl_queue, Component bslstl_priorityqueue
Description:
This component defines a single class template, bsl::stack, a container adapter that takes an underlying container and provides a stack interface which the user accesses primarily through push, pop, and top operations. A deque (the default), vector, or list may be used, but any container which supports push_back, pop_back, back, and size, plus a template specialization uses_allocator::type, may be used.
A stack meets the requirements of a container adaptor as described in the C++ standard [stack]. The stack implemented here adheres to the C++11 standard when compiled with a C++11 compiler, and makes the best approximation when compiled with a C++03 compiler. In particular, for C++03 we emulate move semantics, but limit forwarding (in emplace) to const lvalues, and make no effort to emulate noexcept or initializer-lists.
Requirements on CONTAINER:
The bsl::stack adapter can accept for its (optional) CONTAINER template parameter bsl::deque (the default), bsl::vector, bsl::list, or other container classes that support the following types and methods.
Required Types:
  • value_type
  • reference
  • const_reference
  • size_type
  • allocator_type (if any stack constructor taking an allocator is used)
Required Methods, Free Operators, and Free Functions:
  • void push_back(const value_type&) (and variant taking rvalue reference)
  • void pop_back()
  • reference back()
  • size_type size() const
  • const_reference back() const
  • emplace_back
  • copy-assignment and move-assignment operators
  • free ==, !=, <, >, <=, >= operators
  • free swap function (found via ADL with std::swap in the lookup set)
Requirements on VALUE:
The following term is used to more precisely specify the requirements on template parameter types in function-level documentation:
equality-comparable:
The type provides an equality-comparison operator that defines an equivalence relationship and is both reflexive and transitive.
VALUE and CONTAINER::value_type:
When the CONTAINER template parameter is omitted the VALUE template parameter specifies the value_type of bsl::vector, the default container type. The VALUE template has no other role.
For C++17 and later, the behavior is undefined unless: Prior to C++17, CONTAINER::value_type determines the contained value type and VALUE is simply ignored. The resulting code may work with instances of VALUE (e.g., VALUE is convertible to CONTAINER::value_type) or not (compiler errors).
Memory Allocation:
No memory allocator template arg is directly supplied to this class, the allocator type used is the allocator specified for the container class. Some functions of this template only exist if type CONTAINER::allocator_type exists, and if it does exist it is assumed to be the allocator type used by CONTAINER, and that CONTAINER supports constructors of this type.
bslma-Style Allocators:
The constructors of this class take, as optional parameters, allocators of the object's parameterized CONTAINER::allocator_type type, and allocators of this type are propagated to all constructors of the underlying container. In the case of container types bsl::deque (the default type), bsl::vector, and bsl::list, CONTAINER::allocator_type is bsl::allocator which is implicitly convertible from bslma::Allocator *, and which can be converted to a bslma::Allocator * through the mechanism accessor.
Hence if the underlying container takes bsl::allocator, then the stack object can take bslma_Allocator *s to supply memory allocation. If no allocator is specified, allocator() is used, which winds up using bslma::Default::allocator(0).
Operations:
Below is a list of public methods of the bsl::stack class that effectively forward their implementations to corresponding operations in the held container (referenced as c) which is here assumed to be either bsl::deque, or bsl::vector, or bsl::list.
  Legend
  ------
  'C'             - (template parameter) type 'CONTAINER' of the stack
  'V'             - (template parameter) type 'VALUE'     of the stack
  's', 't'        - two distinct objects of type 'stack<V, C>'

  'nc'            - number of elements in container 'c'
  'n', 'm'        - number of elements in 's' and 't', respectively
  'al'            - STL-style memory allocator
  'v'             - an object of type 'V'

  +----------------------------------------------------+--------------------+
  | Note: the following estimations of operation complexity assume the      |
  | underlying container is a 'bsl::deque', 'bsl::vector', or 'bsl::list'.  |
  +----------------------------------------------------+--------------------+
  | Operation                                          | Complexity         |
  +====================================================+====================+
  | stack<V, C> s;    (default construction)           | O(1)               |
  | stack<V, C> s(al);                                 |                    |
  +----------------------------------------------------+--------------------+
  | stack<V, C> s(c);                                  | O(nc)              |
  | stack<V, C> s(c, al);                              |                    |
  +----------------------------------------------------+--------------------+
  | stack<V, C> s(t);                                  | O(n)               |
  | stack<V, C> s(t, al);                              |                    |
  +----------------------------------------------------+--------------------+
  | s.~stack(V, C>(); (destruction)                    | O(n)               |
  +----------------------------------------------------+--------------------+
  | s = t;          (assignment)                       | O(n)               |
  +----------------------------------------------------+--------------------+
  | s.push(v)                                          | O(1)               |
  +----------------------------------------------------+--------------------+
  | s.pop()                                            | O(1)               |
  +----------------------------------------------------+--------------------+
  | s.top()                                            | O(1)               |
  +----------------------------------------------------+--------------------+
  | s == t, s != t                                     | O(n)               |
  +---------------------------------------------------+--------------------+
  | s < t, s <= t, s > t, s >= t                       | O(n)               |
  +----------------------------------------------------+--------------------+
  | s.swap(t), swap(s,t)                               | depends on the     |
  |                                                    | container; for     |
  |                                                    | deque, vector, and |
  |                                                    | list:              |
  |                                                    | O(1) if 's' and    |
  |                                                    | 't' use the same   |
  |                                                    | allocator,         |
  |                                                    | O(n + m) otherwise |
  +----------------------------------------------------+--------------------+
  | s.size()                                           | O(1) if 'C' is     |
  |                                                    | deque or vector    |
  +----------------------------------------------------+--------------------+
  | s.empty()                                          | O(1)               |
  +----------------------------------------------------+--------------------+
Usage:
In this section we show intended use of this component.
Example 1: Household Chores To Do List:
Suppose a husband wants to keep track of chores his wife has asked him to do. Over the years of being married, he has noticed that his wife generally wants the most recently requested task done first. If she has a new task in mind that is low-priority, she will avoid asking for it until higher priority tasks are finished. When he has finished all tasks, he is to report to his wife that he is ready for more.
First, we define the class implementing the to-do list.
  class ToDoList {
      // DATA
      bsl::stack<const char *> d_stack;

    public:
      // MANIPULATORS
      void enqueueTask(const char *task);
          // Add the specified 'task', a string describing a task, to the
          // list.  Note the lifetime of the string referred to by 'task'
          // must exceed the lifetime of the task in this list.

      bool finishTask();
          // Remove the current task from the list.  Return 'true' if a task
          // was removed and it was the last task on the list, and return
          // 'false' otherwise.

      // ACCESSORS
      const char *currentTask() const;
          // Return the string representing the current task.  If there
          // is no current task, return the string "<EMPTY>", which is
          // not a valid task.
  };

  // MANIPULATORS
  void ToDoList::enqueueTask(const char *task)
  {
      d_stack.push(task);
  }

  bool ToDoList::finishTask()
  {
      if (!d_stack.empty()) {
          d_stack.pop();

          return d_stack.empty();
      }

      return false;
  };

  // ACCESSORS
  const char *ToDoList::currentTask() const
  {
      if (d_stack.empty()) {
          return "<EMPTY>";
      }

      return d_stack.top();
  }
Then, create an object of type ToDoList.
  ToDoList toDoList;
Next, a few tasks are requested:
  toDoList.enqueueTask("Change the car's oil.");
  toDoList.enqueueTask("Pay the bills.");
Then, the husband watches the Yankee's game on TV. Upon returning to the list he consults the list to see what task is up next:
  assert(!strcmp("Pay the bills.", toDoList.currentTask()));
Next, he sees that he has to pay the bills. When the bills are finished, he flushes that task from the list:
  assert(false == toDoList.finishTask());
Then, he consults the list for the next task.
  assert(!strcmp("Change the car's oil.", toDoList.currentTask()));
Next, he sees he has to change the car's oil. Before he can get started, another request comes:
  toDoList.enqueueTask("Get some hot dogs.");
  assert(!strcmp("Get some hot dogs.", toDoList.currentTask()));
Then, he drives the car to the convenience store and picks up some hot dogs and buns. Upon returning home, he gives the hot dogs to his wife, updates the list, and consults it for the next task.
  assert(false == toDoList.finishTask());
  assert(!strcmp("Change the car's oil.", toDoList.currentTask()));
Next, he finishes the oil change, updates the list, and consults it for the next task.
  assert(true == toDoList.finishTask());
  assert(!strcmp("<EMPTY>", toDoList.currentTask()));
Finally, the wife has now been informed that everything is done, and she makes another request:
  toDoList.enqueueTask("Clean the rain gutters.");

Typedef Documentation

template<class VALUE, class CONTAINER = deque<VALUE>>
typedef CONTAINER::value_type bsl::stack< VALUE, CONTAINER >::value_type [inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
typedef CONTAINER::reference bsl::stack< VALUE, CONTAINER >::reference [inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
typedef CONTAINER::const_reference bsl::stack< VALUE, CONTAINER >::const_reference [inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
typedef CONTAINER::size_type bsl::stack< VALUE, CONTAINER >::size_type [inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
typedef CONTAINER bsl::stack< VALUE, CONTAINER >::container_type [inherited]

Function Documentation

template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( stack< VALUE, CONTAINER >  ,
BloombergLP::bslma::UsesBslmaAllocator  ,
BloombergLP::bslma::UsesBslmaAllocator< container_type >::value   
) [inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::stack (  )  [explicit, inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::stack ( const stack< VALUE, CONTAINER > &  original  )  [inherited]

Create a stack having the value of the specified original. The currently installed default allocator is used to supply memory.

template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::stack ( BloombergLP::bslmf::MovableRef< stack< VALUE, CONTAINER > >  original  )  [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::stack ( const CONTAINER &  container  )  [explicit, inherited]

Create a stack whose underlying container has the value of the specified container. The currently installed default allocator is used to supply memory.

template<class VALUE, class CONTAINER = deque<VALUE>>
bsl::stack< VALUE, CONTAINER >::stack ( BloombergLP::bslmf::MovableRef< CONTAINER >  container  )  [explicit, inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class ALLOCATOR >
bsl::stack< VALUE, CONTAINER >::stack ( const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [explicit, inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class ALLOCATOR >
bsl::stack< VALUE, CONTAINER >::stack ( const CONTAINER &  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class ALLOCATOR >
bsl::stack< VALUE, CONTAINER >::stack ( const stack< VALUE, CONTAINER > &  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class ALLOCATOR >
bsl::stack< VALUE, CONTAINER >::stack ( BloombergLP::bslmf::MovableRef< CONTAINER >  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class ALLOCATOR >
bsl::stack< VALUE, CONTAINER >::stack ( BloombergLP::bslmf::MovableRef< stack< VALUE, CONTAINER > >  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

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. Note that a 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.

template<class VALUE, class CONTAINER = deque<VALUE>>
stack& bsl::stack< VALUE, CONTAINER >::operator= ( const stack< VALUE, CONTAINER > &  rhs  )  [inherited]

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

template<class VALUE, class CONTAINER = deque<VALUE>>
stack& bsl::stack< VALUE, CONTAINER >::operator= ( BloombergLP::bslmf::MovableRef< stack< VALUE, CONTAINER > >  rhs  )  [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class... Args>
reference bsl::stack< VALUE, CONTAINER >::emplace ( Args &&...  args  )  [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
void bsl::stack< VALUE, CONTAINER >::pop (  )  [inherited]

Remove the top element from this stack. The behavior is undefined if this stack is empty.

template<class VALUE, class CONTAINER = deque<VALUE>>
void bsl::stack< VALUE, CONTAINER >::push ( const value_type value  )  [inherited]

Push the specified value onto the top of this stack.

template<class VALUE, class CONTAINER = deque<VALUE>>
void bsl::stack< VALUE, CONTAINER >::push ( BloombergLP::bslmf::MovableRef< value_type value  )  [inherited]

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.

template<class VALUE, class CONTAINER = deque<VALUE>>
bool bsl::stack< VALUE, CONTAINER >::empty (  )  const [inherited]

Return true if this stack contains no elements and false otherwise.

template<class VALUE, class CONTAINER = deque<VALUE>>
size_type bsl::stack< VALUE, CONTAINER >::size (  )  const [inherited]

Return the number of elements contained in this stack.

template<class VALUE, class CONTAINER = deque<VALUE>>
const_reference bsl::stack< VALUE, CONTAINER >::top (  )  const [inherited]

Return a reference providing non-modifiable access to the element at the top of this stack. The behavior is undefined if the stack is empty.

template<class VALUE , class CONTAINER >
bool bsl::operator== ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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).

template<class VALUE , class CONTAINER >
bool bsl::operator!= ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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).

template<class VALUE , class CONTAINER >
bool bsl::operator< ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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.

template<class VALUE , class CONTAINER >
bool bsl::operator> ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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.

template<class VALUE , class CONTAINER >
bool bsl::operator<= ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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).

template<class VALUE , class CONTAINER >
bool bsl::operator>= ( const stack< VALUE, CONTAINER > &  lhs,
const stack< VALUE, CONTAINER > &  rhs 
)

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).

template<class VALUE , class CONTAINER >
void bsl::swap ( stack< VALUE, CONTAINER > &  lhs,
stack< VALUE, CONTAINER > &  rhs 
)

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


Variable Documentation

template<class VALUE, class CONTAINER = deque<VALUE>>
container_type bsl::stack< VALUE, CONTAINER >::c [protected, inherited]

We are required by the standard to have the

template<class VALUE, class CONTAINER = deque<VALUE>>
void swap (stack& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( bsl reference bsl::stack< VALUE, CONTAINER >::top() [inherited]

< 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. The behavior is undefined if this stack is empty.


Friends

template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator== ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator!= ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator< ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator> ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator<= ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]
template<class VALUE, class CONTAINER = deque<VALUE>>
template<class VAL , class CONT >
bool operator>= ( const stack< VAL, CONT > &  ,
const stack< VAL, CONT > &   
) [friend, inherited]