tmp/tmpidsvqr97/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### Class template `stack` <a id="stack">[[stack]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
Any sequence container supporting operations `back()`, `push_back()` and
|
| 4 |
`pop_back()` can be used to instantiate `stack`. In particular, `vector`
|
| 5 |
[[vector]], `list` [[list]] and `deque` [[deque]] can be used.
|
| 6 |
|
| 7 |
#### Definition <a id="stack.defn">[[stack.defn]]</a>
|
|
@@ -22,22 +24,30 @@ namespace std {
|
|
| 22 |
|
| 23 |
public:
|
| 24 |
stack() : stack(Container()) {}
|
| 25 |
explicit stack(const Container&);
|
| 26 |
explicit stack(Container&&);
|
|
|
|
|
|
|
| 27 |
template<class Alloc> explicit stack(const Alloc&);
|
| 28 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 29 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 30 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 31 |
template<class Alloc> stack(stack&&, const Alloc&);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 34 |
size_type size() const { return c.size(); }
|
| 35 |
reference top() { return c.back(); }
|
| 36 |
const_reference top() const { return c.back(); }
|
| 37 |
void push(const value_type& x) { c.push_back(x); }
|
| 38 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
|
|
|
|
|
|
| 39 |
template<class... Args>
|
| 40 |
decltype(auto) emplace(Args&&... args)
|
| 41 |
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 42 |
void pop() { c.pop_back(); }
|
| 43 |
void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
|
|
@@ -45,13 +55,28 @@ namespace std {
|
|
| 45 |
};
|
| 46 |
|
| 47 |
template<class Container>
|
| 48 |
stack(Container) -> stack<typename Container::value_type, Container>;
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
template<class Container, class Allocator>
|
| 51 |
stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
template<class T, class Container, class Alloc>
|
| 54 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 55 |
: uses_allocator<Container, Alloc>::type { };
|
| 56 |
}
|
| 57 |
```
|
|
@@ -68,10 +93,26 @@ explicit stack(const Container& cont);
|
|
| 68 |
explicit stack(Container&& cont);
|
| 69 |
```
|
| 70 |
|
| 71 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
#### Constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
|
| 74 |
|
| 75 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 76 |
in this subclause shall not participate in overload resolution.
|
| 77 |
|
|
@@ -107,10 +148,36 @@ template<class Alloc> stack(stack&& s, const Alloc& a);
|
|
| 107 |
```
|
| 108 |
|
| 109 |
*Effects:* Initializes `c` with `std::move(s.c)` as the first argument
|
| 110 |
and `a` as the second argument.
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
#### Operators <a id="stack.ops">[[stack.ops]]</a>
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
template<class T, class Container>
|
| 116 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
| 1 |
### Class template `stack` <a id="stack">[[stack]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="stack.general">[[stack.general]]</a>
|
| 4 |
+
|
| 5 |
Any sequence container supporting operations `back()`, `push_back()` and
|
| 6 |
`pop_back()` can be used to instantiate `stack`. In particular, `vector`
|
| 7 |
[[vector]], `list` [[list]] and `deque` [[deque]] can be used.
|
| 8 |
|
| 9 |
#### Definition <a id="stack.defn">[[stack.defn]]</a>
|
|
|
|
| 24 |
|
| 25 |
public:
|
| 26 |
stack() : stack(Container()) {}
|
| 27 |
explicit stack(const Container&);
|
| 28 |
explicit stack(Container&&);
|
| 29 |
+
template<class InputIterator> stack(InputIterator first, InputIterator last);
|
| 30 |
+
template<container-compatible-range<T> R> stack(from_range_t, R&& rg);
|
| 31 |
template<class Alloc> explicit stack(const Alloc&);
|
| 32 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 33 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 34 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 35 |
template<class Alloc> stack(stack&&, const Alloc&);
|
| 36 |
+
template<class InputIterator, class Alloc>
|
| 37 |
+
stack(InputIterator first, InputIterator last, const Alloc&);
|
| 38 |
+
template<container-compatible-range<T> R, class Alloc>
|
| 39 |
+
stack(from_range_t, R&& rg, const Alloc&);
|
| 40 |
|
| 41 |
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 42 |
size_type size() const { return c.size(); }
|
| 43 |
reference top() { return c.back(); }
|
| 44 |
const_reference top() const { return c.back(); }
|
| 45 |
void push(const value_type& x) { c.push_back(x); }
|
| 46 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 47 |
+
template<container-compatible-range<T> R>
|
| 48 |
+
void push_range(R&& rg);
|
| 49 |
template<class... Args>
|
| 50 |
decltype(auto) emplace(Args&&... args)
|
| 51 |
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 52 |
void pop() { c.pop_back(); }
|
| 53 |
void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
|
|
|
|
| 55 |
};
|
| 56 |
|
| 57 |
template<class Container>
|
| 58 |
stack(Container) -> stack<typename Container::value_type, Container>;
|
| 59 |
|
| 60 |
+
template<class InputIterator>
|
| 61 |
+
stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>;
|
| 62 |
+
|
| 63 |
+
template<ranges::input_range R>
|
| 64 |
+
stack(from_range_t, R&&) -> stack<ranges::range_value_t<R>>;
|
| 65 |
+
|
| 66 |
template<class Container, class Allocator>
|
| 67 |
stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
|
| 68 |
|
| 69 |
+
template<class InputIterator, class Allocator>
|
| 70 |
+
stack(InputIterator, InputIterator, Allocator)
|
| 71 |
+
-> stack<iter-value-type<InputIterator>, deque<iter-value-type<InputIterator>,
|
| 72 |
+
Allocator>>;
|
| 73 |
+
|
| 74 |
+
template<ranges::input_range R, class Allocator>
|
| 75 |
+
stack(from_range_t, R&&, Allocator)
|
| 76 |
+
-> stack<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>;
|
| 77 |
+
|
| 78 |
template<class T, class Container, class Alloc>
|
| 79 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 80 |
: uses_allocator<Container, Alloc>::type { };
|
| 81 |
}
|
| 82 |
```
|
|
|
|
| 93 |
explicit stack(Container&& cont);
|
| 94 |
```
|
| 95 |
|
| 96 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 97 |
|
| 98 |
+
``` cpp
|
| 99 |
+
template<class InputIterator>
|
| 100 |
+
stack(InputIterator first, InputIterator last);
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
*Effects:* Initializes `c` with `first` as the first argument and `last`
|
| 104 |
+
as the second argument.
|
| 105 |
+
|
| 106 |
+
``` cpp
|
| 107 |
+
template<container-compatible-range<T> R>
|
| 108 |
+
stack(from_range_t, R&& rg);
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
*Effects:* Initializes `c` with
|
| 112 |
+
`ranges::to<Container>(std::forward<R>(rg))`.
|
| 113 |
+
|
| 114 |
#### Constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
|
| 115 |
|
| 116 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 117 |
in this subclause shall not participate in overload resolution.
|
| 118 |
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
*Effects:* Initializes `c` with `std::move(s.c)` as the first argument
|
| 151 |
and `a` as the second argument.
|
| 152 |
|
| 153 |
+
``` cpp
|
| 154 |
+
template<class InputIterator, class Alloc>
|
| 155 |
+
stack(InputIterator first, InputIterator last, const Alloc& alloc);
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
*Effects:* Initializes `c` with `first` as the first argument, `last` as
|
| 159 |
+
the second argument, and `alloc` as the third argument.
|
| 160 |
+
|
| 161 |
+
``` cpp
|
| 162 |
+
template<container-compatible-range<T> R, class Alloc>
|
| 163 |
+
stack(from_range_t, R&& rg, const Alloc& a);
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
*Effects:* Initializes `c` with
|
| 167 |
+
`ranges::to<Container>(std::forward<R>(rg), a)`.
|
| 168 |
+
|
| 169 |
+
#### Modifiers <a id="stack.mod">[[stack.mod]]</a>
|
| 170 |
+
|
| 171 |
+
``` cpp
|
| 172 |
+
template<container-compatible-range<T> R>
|
| 173 |
+
void push_range(R&& rg);
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
*Effects:* Equivalent to `c.append_range(std::forward<R>(rg))` if that
|
| 177 |
+
is a valid expression, otherwise `ranges::copy(rg, back_inserter(c))`.
|
| 178 |
+
|
| 179 |
#### Operators <a id="stack.ops">[[stack.ops]]</a>
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
template<class T, class Container>
|
| 183 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|