| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_STACK_H |
| 17 |
#define CPPREFERENCE_STACK_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
#include <initializer_list> |
| 21 |
#endif |
| 22 |
|
| 23 |
namespace std { |
| 24 |
|
| 25 |
template < |
| 26 |
class T, |
| 27 |
class Container = std::deque<T> |
| 28 |
> class stack { |
| 29 |
public: |
| 30 |
typedef Container container_type; |
| 31 |
typedef typename Container::value_type value_type; |
| 32 |
typedef typename Container::size_type size_type; |
| 33 |
typedef typename Container::reference reference; |
| 34 |
typedef typename Container::const_reference const_reference; |
| 35 |
|
| 36 |
#if CPPREFERENCE_STDVER <2011 |
| 37 |
explicit stack(const Container& cont = Container()); |
| 38 |
#else |
| 39 |
explicit stack(const Container& cont); |
| 40 |
explicit stack(Container&& cont = Container()); |
| 41 |
stack(const stack& other); |
| 42 |
stack(stack&& other); |
| 43 |
|
| 44 |
template<class Alloc> |
| 45 |
explicit stack(const Alloc& alloc); |
| 46 |
|
| 47 |
template<class Alloc> |
| 48 |
stack(const Container& cont, const Alloc& alloc); |
| 49 |
|
| 50 |
template<class Alloc> |
| 51 |
stack(Container&& cont, const Alloc& alloc); |
| 52 |
|
| 53 |
template<class Alloc> |
| 54 |
stack(const stack& other, const Alloc& alloc); |
| 55 |
|
| 56 |
template<class Alloc> |
| 57 |
stack(stack&& other, const Alloc& alloc); |
| 58 |
#endif |
| 59 |
|
| 60 |
~stack(); |
| 61 |
|
| 62 |
stack<T, Container>& |
| 63 |
operator=(const stack<T, Container>& other); |
| 64 |
|
| 65 |
#if CPPREFERENCE_STDVER>= 2011 |
| 66 |
stack<T, Container>& |
| 67 |
operator=(stack<T, Container>&& other); |
| 68 |
#endif |
| 69 |
|
| 70 |
reference top(); |
| 71 |
const_reference top() const; |
| 72 |
|
| 73 |
bool empty() const; |
| 74 |
size_type size() const; |
| 75 |
|
| 76 |
void push(const T& value); |
| 77 |
|
| 78 |
#if CPPREFERENCE_STDVER>= 2011 |
| 79 |
void push(T&& value); |
| 80 |
template<class... Args> |
| 81 |
void emplace(Args&& ... args); |
| 82 |
#endif |
| 83 |
|
| 84 |
void pop(); |
| 85 |
|
| 86 |
#if CPPREFERENCE_STDVER>= 2011 |
| 87 |
void swap(stack& other); |
| 88 |
#endif |
| 89 |
|
| 90 |
protected: |
| 91 |
Container c; |
| 92 |
}; |
| 93 |
|
| 94 |
template<class T, class Container> |
| 95 |
bool operator==(stack<T, Container>& lhs, |
| 96 |
stack<T, Container>& rhs); |
| 97 |
|
| 98 |
template<class T, class Container> |
| 99 |
bool operator!=(stack<T, Container>& lhs, |
| 100 |
stack<T, Container>& rhs); |
| 101 |
|
| 102 |
template<class T, class Container> |
| 103 |
bool operator<(stack<T, Container>& lhs, |
| 104 |
stack<T, Container>& rhs); |
| 105 |
|
| 106 |
template<class T, class Container> |
| 107 |
bool operator<=(stack<T, Container>& lhs, |
| 108 |
stack<T, Container>& rhs); |
| 109 |
|
| 110 |
template<class T, class Container> |
| 111 |
bool operator>(stack<T, Container>& lhs, |
| 112 |
stack<T, Container>& rhs); |
| 113 |
|
| 114 |
template<class T, class Container> |
| 115 |
bool operator>=(stack<T, Container>& lhs, |
| 116 |
stack<T, Container>& rhs); |
| 117 |
|
| 118 |
template<class T, class Container> |
| 119 |
void swap(stack<T, Container>& lhs, |
| 120 |
stack<T, Container>& rhs); |
| 121 |
|
| 122 |
|
| 123 |
} // namespace std |
| 124 |
|
| 125 |
#endif // CPPREFERENCE_STACK_H |