tmp/tmpqlm6g371/{from.md → to.md}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
### Class template `queue` <a id="queue">[[queue]]</a>
|
| 2 |
|
| 3 |
-
####
|
| 4 |
|
| 5 |
Any sequence container supporting operations `front()`, `back()`,
|
| 6 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 7 |
-
particular, `list`
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class T, class Container = deque<T>>
|
| 12 |
class queue {
|
|
@@ -19,28 +19,30 @@ namespace std {
|
|
| 19 |
|
| 20 |
protected:
|
| 21 |
Container c;
|
| 22 |
|
| 23 |
public:
|
|
|
|
| 24 |
explicit queue(const Container&);
|
| 25 |
-
explicit queue(Container&&
|
| 26 |
template<class Alloc> explicit queue(const Alloc&);
|
| 27 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 28 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 29 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 30 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 31 |
|
| 32 |
-
bool
|
| 33 |
size_type size() const { return c.size(); }
|
| 34 |
reference front() { return c.front(); }
|
| 35 |
const_reference front() const { return c.front(); }
|
| 36 |
reference back() { return c.back(); }
|
| 37 |
const_reference back() const { return c.back(); }
|
| 38 |
void push(const value_type& x) { c.push_back(x); }
|
| 39 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 40 |
template<class... Args>
|
| 41 |
-
|
|
|
|
| 42 |
void pop() { c.pop_front(); }
|
| 43 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
| 44 |
{ using std::swap; swap(c, q.c); }
|
| 45 |
};
|
| 46 |
|
|
@@ -48,86 +50,73 @@ namespace std {
|
|
| 48 |
queue(Container) -> queue<typename Container::value_type, Container>;
|
| 49 |
|
| 50 |
template<class Container, class Allocator>
|
| 51 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
|
| 52 |
|
| 53 |
-
template <class T, class Container>
|
| 54 |
-
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 55 |
-
template <class T, class Container>
|
| 56 |
-
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 57 |
-
template <class T, class Container>
|
| 58 |
-
bool operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 59 |
-
template <class T, class Container>
|
| 60 |
-
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 61 |
-
template <class T, class Container>
|
| 62 |
-
bool operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 63 |
-
template <class T, class Container>
|
| 64 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 65 |
-
|
| 66 |
template<class T, class Container>
|
| 67 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 68 |
|
| 69 |
template<class T, class Container, class Alloc>
|
| 70 |
struct uses_allocator<queue<T, Container>, Alloc>
|
| 71 |
: uses_allocator<Container, Alloc>::type { };
|
| 72 |
}
|
| 73 |
```
|
| 74 |
|
| 75 |
-
####
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
explicit queue(const Container& cont);
|
| 79 |
```
|
| 80 |
|
| 81 |
-
*Effects:*
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
explicit queue(Container&& cont
|
| 85 |
```
|
| 86 |
|
| 87 |
-
*Effects:*
|
| 88 |
|
| 89 |
-
####
|
| 90 |
|
| 91 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 92 |
in this subclause shall not participate in overload resolution.
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
template<class Alloc> explicit queue(const Alloc& a);
|
| 96 |
```
|
| 97 |
|
| 98 |
-
*Effects:*
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
template<class Alloc> queue(const container_type& cont, const Alloc& a);
|
| 102 |
```
|
| 103 |
|
| 104 |
-
*Effects:*
|
| 105 |
the second argument.
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
template<class Alloc> queue(container_type&& cont, const Alloc& a);
|
| 109 |
```
|
| 110 |
|
| 111 |
-
*Effects:*
|
| 112 |
and `a` as the second argument.
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
template<class Alloc> queue(const queue& q, const Alloc& a);
|
| 116 |
```
|
| 117 |
|
| 118 |
-
*Effects:*
|
| 119 |
the second argument.
|
| 120 |
|
| 121 |
``` cpp
|
| 122 |
template<class Alloc> queue(queue&& q, const Alloc& a);
|
| 123 |
```
|
| 124 |
|
| 125 |
-
*Effects:*
|
| 126 |
and `a` as the second argument.
|
| 127 |
|
| 128 |
-
####
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
template<class T, class Container>
|
| 132 |
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 133 |
```
|
|
@@ -146,39 +135,46 @@ template <class T, class Container>
|
|
| 146 |
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 147 |
```
|
| 148 |
|
| 149 |
*Returns:* `x.c < y.c`.
|
| 150 |
|
| 151 |
-
``` cpp
|
| 152 |
-
template <class T, class Container>
|
| 153 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 154 |
-
```
|
| 155 |
-
|
| 156 |
-
*Returns:* `x.c <= y.c`.
|
| 157 |
-
|
| 158 |
``` cpp
|
| 159 |
template<class T, class Container>
|
| 160 |
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 161 |
```
|
| 162 |
|
| 163 |
*Returns:* `x.c > y.c`.
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
``` cpp
|
| 166 |
template<class T, class Container>
|
| 167 |
bool operator>=(const queue<T, Container>& x,
|
| 168 |
const queue<T, Container>& y);
|
| 169 |
```
|
| 170 |
|
| 171 |
*Returns:* `x.c >= y.c`.
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
template<class T, class Container>
|
| 177 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 178 |
```
|
| 179 |
|
| 180 |
-
*
|
| 181 |
-
unless `is_swappable_v<Container>` is `true`.
|
| 182 |
|
| 183 |
*Effects:* As if by `x.swap(y)`.
|
| 184 |
|
|
|
|
| 1 |
### Class template `queue` <a id="queue">[[queue]]</a>
|
| 2 |
|
| 3 |
+
#### Definition <a id="queue.defn">[[queue.defn]]</a>
|
| 4 |
|
| 5 |
Any sequence container supporting operations `front()`, `back()`,
|
| 6 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 7 |
+
particular, `list` [[list]] and `deque` [[deque]] can be used.
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class T, class Container = deque<T>>
|
| 12 |
class queue {
|
|
|
|
| 19 |
|
| 20 |
protected:
|
| 21 |
Container c;
|
| 22 |
|
| 23 |
public:
|
| 24 |
+
queue() : queue(Container()) {}
|
| 25 |
explicit queue(const Container&);
|
| 26 |
+
explicit queue(Container&&);
|
| 27 |
template<class Alloc> explicit queue(const Alloc&);
|
| 28 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 29 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 30 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 31 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 32 |
|
| 33 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 34 |
size_type size() const { return c.size(); }
|
| 35 |
reference front() { return c.front(); }
|
| 36 |
const_reference front() const { return c.front(); }
|
| 37 |
reference back() { return c.back(); }
|
| 38 |
const_reference back() const { return c.back(); }
|
| 39 |
void push(const value_type& x) { c.push_back(x); }
|
| 40 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 41 |
template<class... Args>
|
| 42 |
+
decltype(auto) emplace(Args&&... args)
|
| 43 |
+
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 44 |
void pop() { c.pop_front(); }
|
| 45 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
| 46 |
{ using std::swap; swap(c, q.c); }
|
| 47 |
};
|
| 48 |
|
|
|
|
| 50 |
queue(Container) -> queue<typename Container::value_type, Container>;
|
| 51 |
|
| 52 |
template<class Container, class Allocator>
|
| 53 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
template<class T, class Container>
|
| 56 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 57 |
|
| 58 |
template<class T, class Container, class Alloc>
|
| 59 |
struct uses_allocator<queue<T, Container>, Alloc>
|
| 60 |
: uses_allocator<Container, Alloc>::type { };
|
| 61 |
}
|
| 62 |
```
|
| 63 |
|
| 64 |
+
#### Constructors <a id="queue.cons">[[queue.cons]]</a>
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
explicit queue(const Container& cont);
|
| 68 |
```
|
| 69 |
|
| 70 |
+
*Effects:* Initializes `c` with `cont`.
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
+
explicit queue(Container&& cont);
|
| 74 |
```
|
| 75 |
|
| 76 |
+
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 77 |
|
| 78 |
+
#### Constructors with allocators <a id="queue.cons.alloc">[[queue.cons.alloc]]</a>
|
| 79 |
|
| 80 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 81 |
in this subclause shall not participate in overload resolution.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
template<class Alloc> explicit queue(const Alloc& a);
|
| 85 |
```
|
| 86 |
|
| 87 |
+
*Effects:* Initializes `c` with `a`.
|
| 88 |
|
| 89 |
``` cpp
|
| 90 |
template<class Alloc> queue(const container_type& cont, const Alloc& a);
|
| 91 |
```
|
| 92 |
|
| 93 |
+
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 94 |
the second argument.
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
template<class Alloc> queue(container_type&& cont, const Alloc& a);
|
| 98 |
```
|
| 99 |
|
| 100 |
+
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 101 |
and `a` as the second argument.
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
template<class Alloc> queue(const queue& q, const Alloc& a);
|
| 105 |
```
|
| 106 |
|
| 107 |
+
*Effects:* Initializes `c` with `q.c` as the first argument and `a` as
|
| 108 |
the second argument.
|
| 109 |
|
| 110 |
``` cpp
|
| 111 |
template<class Alloc> queue(queue&& q, const Alloc& a);
|
| 112 |
```
|
| 113 |
|
| 114 |
+
*Effects:* Initializes `c` with `std::move(q.c)` as the first argument
|
| 115 |
and `a` as the second argument.
|
| 116 |
|
| 117 |
+
#### Operators <a id="queue.ops">[[queue.ops]]</a>
|
| 118 |
|
| 119 |
``` cpp
|
| 120 |
template<class T, class Container>
|
| 121 |
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 122 |
```
|
|
|
|
| 135 |
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 136 |
```
|
| 137 |
|
| 138 |
*Returns:* `x.c < y.c`.
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
``` cpp
|
| 141 |
template<class T, class Container>
|
| 142 |
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 143 |
```
|
| 144 |
|
| 145 |
*Returns:* `x.c > y.c`.
|
| 146 |
|
| 147 |
+
``` cpp
|
| 148 |
+
template<class T, class Container>
|
| 149 |
+
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
*Returns:* `x.c <= y.c`.
|
| 153 |
+
|
| 154 |
``` cpp
|
| 155 |
template<class T, class Container>
|
| 156 |
bool operator>=(const queue<T, Container>& x,
|
| 157 |
const queue<T, Container>& y);
|
| 158 |
```
|
| 159 |
|
| 160 |
*Returns:* `x.c >= y.c`.
|
| 161 |
|
| 162 |
+
``` cpp
|
| 163 |
+
template<class T, three_way_comparable Container>
|
| 164 |
+
compare_three_way_result_t<Container>
|
| 165 |
+
operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
*Returns:* `x.c <=> y.c`.
|
| 169 |
+
|
| 170 |
+
#### Specialized algorithms <a id="queue.special">[[queue.special]]</a>
|
| 171 |
|
| 172 |
``` cpp
|
| 173 |
template<class T, class Container>
|
| 174 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 175 |
```
|
| 176 |
|
| 177 |
+
*Constraints:* `is_swappable_v<Container>` is `true`.
|
|
|
|
| 178 |
|
| 179 |
*Effects:* As if by `x.swap(y)`.
|
| 180 |
|