- tmp/tmp5rr271ie/{from.md → to.md} +136 -303
tmp/tmp5rr271ie/{from.md → to.md}
RENAMED
|
@@ -33,70 +33,88 @@ overload resolution if any of the following are true:
|
|
| 33 |
`uses_allocator_v<Container, Allocator>` is `false`.
|
| 34 |
|
| 35 |
### Header `<queue>` synopsis <a id="queue.syn">[[queue.syn]]</a>
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
-
#include <
|
|
|
|
| 39 |
|
| 40 |
namespace std {
|
| 41 |
template<class T, class Container = deque<T>> class queue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
template<class T, class Container = vector<T>,
|
| 43 |
class Compare = less<typename Container::value_type>>
|
| 44 |
class priority_queue;
|
| 45 |
|
| 46 |
-
template <class T, class Container>
|
| 47 |
-
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 48 |
-
template <class T, class Container>
|
| 49 |
-
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 50 |
-
template <class T, class Container>
|
| 51 |
-
bool operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 52 |
-
template <class T, class Container>
|
| 53 |
-
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 54 |
-
template <class T, class Container>
|
| 55 |
-
bool operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 56 |
-
template <class T, class Container>
|
| 57 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 58 |
-
|
| 59 |
-
template <class T, class Container>
|
| 60 |
-
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 61 |
template<class T, class Container, class Compare>
|
| 62 |
void swap(priority_queue<T, Container, Compare>& x,
|
| 63 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
```
|
| 66 |
|
| 67 |
### Header `<stack>` synopsis <a id="stack.syn">[[stack.syn]]</a>
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
-
#include <
|
|
|
|
| 71 |
|
| 72 |
namespace std {
|
| 73 |
template<class T, class Container = deque<T>> class stack;
|
|
|
|
| 74 |
template<class T, class Container>
|
| 75 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 76 |
-
template <class T, class Container>
|
| 77 |
-
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 78 |
template<class T, class Container>
|
| 79 |
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
|
|
|
| 80 |
template<class T, class Container>
|
| 81 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 82 |
-
template <class T, class Container>
|
| 83 |
-
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 84 |
template<class T, class Container>
|
| 85 |
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
template<class T, class Container>
|
| 87 |
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
```
|
| 90 |
|
| 91 |
### Class template `queue` <a id="queue">[[queue]]</a>
|
| 92 |
|
| 93 |
-
####
|
| 94 |
|
| 95 |
Any sequence container supporting operations `front()`, `back()`,
|
| 96 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 97 |
-
particular, `list`
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
namespace std {
|
| 101 |
template<class T, class Container = deque<T>>
|
| 102 |
class queue {
|
|
@@ -109,28 +127,30 @@ namespace std {
|
|
| 109 |
|
| 110 |
protected:
|
| 111 |
Container c;
|
| 112 |
|
| 113 |
public:
|
|
|
|
| 114 |
explicit queue(const Container&);
|
| 115 |
-
explicit queue(Container&&
|
| 116 |
template<class Alloc> explicit queue(const Alloc&);
|
| 117 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 118 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 119 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 120 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 121 |
|
| 122 |
-
bool
|
| 123 |
size_type size() const { return c.size(); }
|
| 124 |
reference front() { return c.front(); }
|
| 125 |
const_reference front() const { return c.front(); }
|
| 126 |
reference back() { return c.back(); }
|
| 127 |
const_reference back() const { return c.back(); }
|
| 128 |
void push(const value_type& x) { c.push_back(x); }
|
| 129 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 130 |
template<class... Args>
|
| 131 |
-
|
|
|
|
| 132 |
void pop() { c.pop_front(); }
|
| 133 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
| 134 |
{ using std::swap; swap(c, q.c); }
|
| 135 |
};
|
| 136 |
|
|
@@ -138,86 +158,73 @@ namespace std {
|
|
| 138 |
queue(Container) -> queue<typename Container::value_type, Container>;
|
| 139 |
|
| 140 |
template<class Container, class Allocator>
|
| 141 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
|
| 142 |
|
| 143 |
-
template <class T, class Container>
|
| 144 |
-
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 145 |
-
template <class T, class Container>
|
| 146 |
-
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 147 |
-
template <class T, class Container>
|
| 148 |
-
bool operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 149 |
-
template <class T, class Container>
|
| 150 |
-
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 151 |
-
template <class T, class Container>
|
| 152 |
-
bool operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 153 |
-
template <class T, class Container>
|
| 154 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 155 |
-
|
| 156 |
template<class T, class Container>
|
| 157 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 158 |
|
| 159 |
template<class T, class Container, class Alloc>
|
| 160 |
struct uses_allocator<queue<T, Container>, Alloc>
|
| 161 |
: uses_allocator<Container, Alloc>::type { };
|
| 162 |
}
|
| 163 |
```
|
| 164 |
|
| 165 |
-
####
|
| 166 |
|
| 167 |
``` cpp
|
| 168 |
explicit queue(const Container& cont);
|
| 169 |
```
|
| 170 |
|
| 171 |
-
*Effects:*
|
| 172 |
|
| 173 |
``` cpp
|
| 174 |
-
explicit queue(Container&& cont
|
| 175 |
```
|
| 176 |
|
| 177 |
-
*Effects:*
|
| 178 |
|
| 179 |
-
####
|
| 180 |
|
| 181 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 182 |
in this subclause shall not participate in overload resolution.
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
template<class Alloc> explicit queue(const Alloc& a);
|
| 186 |
```
|
| 187 |
|
| 188 |
-
*Effects:*
|
| 189 |
|
| 190 |
``` cpp
|
| 191 |
template<class Alloc> queue(const container_type& cont, const Alloc& a);
|
| 192 |
```
|
| 193 |
|
| 194 |
-
*Effects:*
|
| 195 |
the second argument.
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
template<class Alloc> queue(container_type&& cont, const Alloc& a);
|
| 199 |
```
|
| 200 |
|
| 201 |
-
*Effects:*
|
| 202 |
and `a` as the second argument.
|
| 203 |
|
| 204 |
``` cpp
|
| 205 |
template<class Alloc> queue(const queue& q, const Alloc& a);
|
| 206 |
```
|
| 207 |
|
| 208 |
-
*Effects:*
|
| 209 |
the second argument.
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
template<class Alloc> queue(queue&& q, const Alloc& a);
|
| 213 |
```
|
| 214 |
|
| 215 |
-
*Effects:*
|
| 216 |
and `a` as the second argument.
|
| 217 |
|
| 218 |
-
####
|
| 219 |
|
| 220 |
``` cpp
|
| 221 |
template<class T, class Container>
|
| 222 |
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 223 |
```
|
|
@@ -236,53 +243,62 @@ template <class T, class Container>
|
|
| 236 |
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 237 |
```
|
| 238 |
|
| 239 |
*Returns:* `x.c < y.c`.
|
| 240 |
|
| 241 |
-
``` cpp
|
| 242 |
-
template <class T, class Container>
|
| 243 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 244 |
-
```
|
| 245 |
-
|
| 246 |
-
*Returns:* `x.c <= y.c`.
|
| 247 |
-
|
| 248 |
``` cpp
|
| 249 |
template<class T, class Container>
|
| 250 |
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 251 |
```
|
| 252 |
|
| 253 |
*Returns:* `x.c > y.c`.
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
``` cpp
|
| 256 |
template<class T, class Container>
|
| 257 |
bool operator>=(const queue<T, Container>& x,
|
| 258 |
const queue<T, Container>& y);
|
| 259 |
```
|
| 260 |
|
| 261 |
*Returns:* `x.c >= y.c`.
|
| 262 |
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
template<class T, class Container>
|
| 267 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 268 |
```
|
| 269 |
|
| 270 |
-
*
|
| 271 |
-
unless `is_swappable_v<Container>` is `true`.
|
| 272 |
|
| 273 |
*Effects:* As if by `x.swap(y)`.
|
| 274 |
|
| 275 |
### Class template `priority_queue` <a id="priority.queue">[[priority.queue]]</a>
|
| 276 |
|
|
|
|
|
|
|
| 277 |
Any sequence container with random access iterator and supporting
|
| 278 |
operations `front()`, `push_back()` and `pop_back()` can be used to
|
| 279 |
-
instantiate `priority_queue`. In particular, `vector`
|
| 280 |
-
`deque`
|
| 281 |
involves supplying a function or function object for making priority
|
| 282 |
comparisons; the library assumes that the function or function object
|
| 283 |
-
defines a strict weak ordering
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
namespace std {
|
| 287 |
template<class T, class Container = vector<T>,
|
| 288 |
class Compare = less<typename Container::value_type>>
|
|
@@ -298,26 +314,28 @@ namespace std {
|
|
| 298 |
protected:
|
| 299 |
Container c;
|
| 300 |
Compare comp;
|
| 301 |
|
| 302 |
public:
|
|
|
|
|
|
|
| 303 |
priority_queue(const Compare& x, const Container&);
|
| 304 |
-
|
| 305 |
template<class InputIterator>
|
| 306 |
-
priority_queue(InputIterator first, InputIterator last,
|
| 307 |
-
|
| 308 |
template<class InputIterator>
|
| 309 |
priority_queue(InputIterator first, InputIterator last,
|
| 310 |
const Compare& x = Compare(), Container&& = Container());
|
| 311 |
template<class Alloc> explicit priority_queue(const Alloc&);
|
| 312 |
template<class Alloc> priority_queue(const Compare&, const Alloc&);
|
| 313 |
template<class Alloc> priority_queue(const Compare&, const Container&, const Alloc&);
|
| 314 |
template<class Alloc> priority_queue(const Compare&, Container&&, const Alloc&);
|
| 315 |
template<class Alloc> priority_queue(const priority_queue&, const Alloc&);
|
| 316 |
template<class Alloc> priority_queue(priority_queue&&, const Alloc&);
|
| 317 |
|
| 318 |
-
bool
|
| 319 |
size_type size() const { return c.size(); }
|
| 320 |
const_reference top() const { return c.front(); }
|
| 321 |
void push(const value_type& x);
|
| 322 |
void push(value_type&& x);
|
| 323 |
template<class... Args> void emplace(Args&&... args);
|
|
@@ -351,93 +369,90 @@ namespace std {
|
|
| 351 |
struct uses_allocator<priority_queue<T, Container, Compare>, Alloc>
|
| 352 |
: uses_allocator<Container, Alloc>::type { };
|
| 353 |
}
|
| 354 |
```
|
| 355 |
|
| 356 |
-
####
|
| 357 |
|
| 358 |
``` cpp
|
| 359 |
priority_queue(const Compare& x, const Container& y);
|
| 360 |
-
|
| 361 |
```
|
| 362 |
|
| 363 |
-
*
|
| 364 |
|
| 365 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 366 |
constructing or move constructing as appropriate); calls
|
| 367 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 368 |
|
| 369 |
``` cpp
|
| 370 |
template<class InputIterator>
|
| 371 |
-
priority_queue(InputIterator first, InputIterator last,
|
| 372 |
-
const Compare& x,
|
| 373 |
-
const Container& y);
|
| 374 |
template<class InputIterator>
|
| 375 |
-
priority_queue(InputIterator first, InputIterator last,
|
| 376 |
-
const Compare& x = Compare(),
|
| 377 |
Container&& y = Container());
|
| 378 |
```
|
| 379 |
|
| 380 |
-
*
|
| 381 |
|
| 382 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 383 |
constructing or move constructing as appropriate); calls
|
| 384 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 385 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 386 |
|
| 387 |
-
####
|
| 388 |
|
| 389 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 390 |
in this subclause shall not participate in overload resolution.
|
| 391 |
|
| 392 |
``` cpp
|
| 393 |
template<class Alloc> explicit priority_queue(const Alloc& a);
|
| 394 |
```
|
| 395 |
|
| 396 |
-
*Effects:*
|
| 397 |
|
| 398 |
``` cpp
|
| 399 |
template<class Alloc> priority_queue(const Compare& compare, const Alloc& a);
|
| 400 |
```
|
| 401 |
|
| 402 |
-
*Effects:*
|
| 403 |
`compare`.
|
| 404 |
|
| 405 |
``` cpp
|
| 406 |
template<class Alloc>
|
| 407 |
priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
|
| 408 |
```
|
| 409 |
|
| 410 |
-
*Effects:*
|
| 411 |
the second argument, and initializes `comp` with `compare`; calls
|
| 412 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 413 |
|
| 414 |
``` cpp
|
| 415 |
template<class Alloc>
|
| 416 |
priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
|
| 417 |
```
|
| 418 |
|
| 419 |
-
*Effects:*
|
| 420 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 421 |
calls `make_heap(c.begin(), c.end(), comp)`.
|
| 422 |
|
| 423 |
``` cpp
|
| 424 |
template<class Alloc> priority_queue(const priority_queue& q, const Alloc& a);
|
| 425 |
```
|
| 426 |
|
| 427 |
-
*Effects:*
|
| 428 |
the second argument, and initializes `comp` with `q.comp`.
|
| 429 |
|
| 430 |
``` cpp
|
| 431 |
template<class Alloc> priority_queue(priority_queue&& q, const Alloc& a);
|
| 432 |
```
|
| 433 |
|
| 434 |
-
*Effects:*
|
| 435 |
and `a` as the second argument, and initializes `comp` with
|
| 436 |
`std::move(q.comp)`.
|
| 437 |
|
| 438 |
-
####
|
| 439 |
|
| 440 |
``` cpp
|
| 441 |
void push(const value_type& x);
|
| 442 |
```
|
| 443 |
|
|
@@ -458,11 +473,11 @@ void push(value_type&& x);
|
|
| 458 |
c.push_back(std::move(x));
|
| 459 |
push_heap(c.begin(), c.end(), comp);
|
| 460 |
```
|
| 461 |
|
| 462 |
``` cpp
|
| 463 |
-
template
|
| 464 |
```
|
| 465 |
|
| 466 |
*Effects:* As if by:
|
| 467 |
|
| 468 |
``` cpp
|
|
@@ -479,32 +494,30 @@ void pop();
|
|
| 479 |
``` cpp
|
| 480 |
pop_heap(c.begin(), c.end(), comp);
|
| 481 |
c.pop_back();
|
| 482 |
```
|
| 483 |
|
| 484 |
-
####
|
| 485 |
|
| 486 |
``` cpp
|
| 487 |
template<class T, class Container, class Compare>
|
| 488 |
void swap(priority_queue<T, Container, Compare>& x,
|
| 489 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
| 490 |
```
|
| 491 |
|
| 492 |
-
*
|
| 493 |
-
unless `is_swappable_v<Container>` is `true` and
|
| 494 |
`is_swappable_v<Compare>` is `true`.
|
| 495 |
|
| 496 |
*Effects:* As if by `x.swap(y)`.
|
| 497 |
|
| 498 |
### Class template `stack` <a id="stack">[[stack]]</a>
|
| 499 |
|
| 500 |
Any sequence container supporting operations `back()`, `push_back()` and
|
| 501 |
-
`pop_back()` can be used to instantiate `stack`. In particular,
|
| 502 |
-
|
| 503 |
-
be used.
|
| 504 |
|
| 505 |
-
####
|
| 506 |
|
| 507 |
``` cpp
|
| 508 |
namespace std {
|
| 509 |
template<class T, class Container = deque<T>>
|
| 510 |
class stack {
|
|
@@ -517,26 +530,28 @@ namespace std {
|
|
| 517 |
|
| 518 |
protected:
|
| 519 |
Container c;
|
| 520 |
|
| 521 |
public:
|
|
|
|
| 522 |
explicit stack(const Container&);
|
| 523 |
-
explicit stack(Container&&
|
| 524 |
template<class Alloc> explicit stack(const Alloc&);
|
| 525 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 526 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 527 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 528 |
template<class Alloc> stack(stack&&, const Alloc&);
|
| 529 |
|
| 530 |
-
bool
|
| 531 |
size_type size() const { return c.size(); }
|
| 532 |
reference top() { return c.back(); }
|
| 533 |
const_reference top() const { return c.back(); }
|
| 534 |
void push(const value_type& x) { c.push_back(x); }
|
| 535 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 536 |
template<class... Args>
|
| 537 |
-
|
|
|
|
| 538 |
void pop() { c.pop_back(); }
|
| 539 |
void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
|
| 540 |
{ using std::swap; swap(c, s.c); }
|
| 541 |
};
|
| 542 |
|
|
@@ -544,85 +559,70 @@ namespace std {
|
|
| 544 |
stack(Container) -> stack<typename Container::value_type, Container>;
|
| 545 |
|
| 546 |
template<class Container, class Allocator>
|
| 547 |
stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
|
| 548 |
|
| 549 |
-
template <class T, class Container>
|
| 550 |
-
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 551 |
-
template <class T, class Container>
|
| 552 |
-
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 553 |
-
template <class T, class Container>
|
| 554 |
-
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 555 |
-
template <class T, class Container>
|
| 556 |
-
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 557 |
-
template <class T, class Container>
|
| 558 |
-
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 559 |
-
template <class T, class Container>
|
| 560 |
-
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 561 |
-
template <class T, class Container>
|
| 562 |
-
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 563 |
-
|
| 564 |
template<class T, class Container, class Alloc>
|
| 565 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 566 |
: uses_allocator<Container, Alloc>::type { };
|
| 567 |
}
|
| 568 |
```
|
| 569 |
|
| 570 |
-
####
|
| 571 |
|
| 572 |
``` cpp
|
| 573 |
explicit stack(const Container& cont);
|
| 574 |
```
|
| 575 |
|
| 576 |
*Effects:* Initializes `c` with `cont`.
|
| 577 |
|
| 578 |
``` cpp
|
| 579 |
-
explicit stack(Container&& cont
|
| 580 |
```
|
| 581 |
|
| 582 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 583 |
|
| 584 |
-
####
|
| 585 |
|
| 586 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 587 |
in this subclause shall not participate in overload resolution.
|
| 588 |
|
| 589 |
``` cpp
|
| 590 |
template<class Alloc> explicit stack(const Alloc& a);
|
| 591 |
```
|
| 592 |
|
| 593 |
-
*Effects:*
|
| 594 |
|
| 595 |
``` cpp
|
| 596 |
template<class Alloc> stack(const container_type& cont, const Alloc& a);
|
| 597 |
```
|
| 598 |
|
| 599 |
-
*Effects:*
|
| 600 |
the second argument.
|
| 601 |
|
| 602 |
``` cpp
|
| 603 |
template<class Alloc> stack(container_type&& cont, const Alloc& a);
|
| 604 |
```
|
| 605 |
|
| 606 |
-
*Effects:*
|
| 607 |
and `a` as the second argument.
|
| 608 |
|
| 609 |
``` cpp
|
| 610 |
template<class Alloc> stack(const stack& s, const Alloc& a);
|
| 611 |
```
|
| 612 |
|
| 613 |
-
*Effects:*
|
| 614 |
the second argument.
|
| 615 |
|
| 616 |
``` cpp
|
| 617 |
template<class Alloc> stack(stack&& s, const Alloc& a);
|
| 618 |
```
|
| 619 |
|
| 620 |
-
*Effects:*
|
| 621 |
and `a` as the second argument.
|
| 622 |
|
| 623 |
-
####
|
| 624 |
|
| 625 |
``` cpp
|
| 626 |
template<class T, class Container>
|
| 627 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 628 |
```
|
|
@@ -641,212 +641,45 @@ template <class T, class Container>
|
|
| 641 |
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 642 |
```
|
| 643 |
|
| 644 |
*Returns:* `x.c < y.c`.
|
| 645 |
|
| 646 |
-
``` cpp
|
| 647 |
-
template <class T, class Container>
|
| 648 |
-
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 649 |
-
```
|
| 650 |
-
|
| 651 |
-
*Returns:* `x.c <= y.c`.
|
| 652 |
-
|
| 653 |
``` cpp
|
| 654 |
template<class T, class Container>
|
| 655 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 656 |
```
|
| 657 |
|
| 658 |
*Returns:* `x.c > y.c`.
|
| 659 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 660 |
``` cpp
|
| 661 |
template<class T, class Container>
|
| 662 |
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 663 |
```
|
| 664 |
|
| 665 |
*Returns:* `x.c >= y.c`.
|
| 666 |
|
| 667 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 668 |
|
| 669 |
``` cpp
|
| 670 |
template<class T, class Container>
|
| 671 |
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 672 |
```
|
| 673 |
|
| 674 |
-
*
|
| 675 |
-
unless `is_swappable_v<Container>` is `true`.
|
| 676 |
|
| 677 |
*Effects:* As if by `x.swap(y)`.
|
| 678 |
|
| 679 |
-
<!-- Link reference definitions -->
|
| 680 |
-
[alg.sorting]: algorithms.md#alg.sorting
|
| 681 |
-
[algorithm.stable]: library.md#algorithm.stable
|
| 682 |
-
[algorithms]: algorithms.md#algorithms
|
| 683 |
-
[allocator.requirements]: library.md#allocator.requirements
|
| 684 |
-
[allocator.requirements.completeness]: library.md#allocator.requirements.completeness
|
| 685 |
-
[allocator.traits.members]: utilities.md#allocator.traits.members
|
| 686 |
-
[array]: #array
|
| 687 |
-
[array.cons]: #array.cons
|
| 688 |
-
[array.data]: #array.data
|
| 689 |
-
[array.fill]: #array.fill
|
| 690 |
-
[array.overview]: #array.overview
|
| 691 |
-
[array.size]: #array.size
|
| 692 |
-
[array.special]: #array.special
|
| 693 |
-
[array.swap]: #array.swap
|
| 694 |
-
[array.syn]: #array.syn
|
| 695 |
-
[array.tuple]: #array.tuple
|
| 696 |
-
[array.zero]: #array.zero
|
| 697 |
-
[associative]: #associative
|
| 698 |
-
[associative.general]: #associative.general
|
| 699 |
-
[associative.map.syn]: #associative.map.syn
|
| 700 |
-
[associative.reqmts]: #associative.reqmts
|
| 701 |
-
[associative.reqmts.except]: #associative.reqmts.except
|
| 702 |
-
[associative.set.syn]: #associative.set.syn
|
| 703 |
-
[basic.string]: strings.md#basic.string
|
| 704 |
-
[class.copy]: special.md#class.copy
|
| 705 |
-
[class.ctor]: special.md#class.ctor
|
| 706 |
-
[class.dtor]: special.md#class.dtor
|
| 707 |
-
[container.adaptors]: #container.adaptors
|
| 708 |
-
[container.adaptors.general]: #container.adaptors.general
|
| 709 |
-
[container.insert.return]: #container.insert.return
|
| 710 |
-
[container.node]: #container.node
|
| 711 |
-
[container.node.cons]: #container.node.cons
|
| 712 |
-
[container.node.dtor]: #container.node.dtor
|
| 713 |
-
[container.node.modifiers]: #container.node.modifiers
|
| 714 |
-
[container.node.observers]: #container.node.observers
|
| 715 |
-
[container.node.overview]: #container.node.overview
|
| 716 |
-
[container.requirements]: #container.requirements
|
| 717 |
-
[container.requirements.dataraces]: #container.requirements.dataraces
|
| 718 |
-
[container.requirements.general]: #container.requirements.general
|
| 719 |
-
[containers]: #containers
|
| 720 |
-
[containers.general]: #containers.general
|
| 721 |
-
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 722 |
-
[deque]: #deque
|
| 723 |
-
[deque.capacity]: #deque.capacity
|
| 724 |
-
[deque.cons]: #deque.cons
|
| 725 |
-
[deque.modifiers]: #deque.modifiers
|
| 726 |
-
[deque.overview]: #deque.overview
|
| 727 |
-
[deque.special]: #deque.special
|
| 728 |
-
[deque.syn]: #deque.syn
|
| 729 |
-
[forward.iterators]: iterators.md#forward.iterators
|
| 730 |
-
[forward_list.syn]: #forward_list.syn
|
| 731 |
-
[forwardlist]: #forwardlist
|
| 732 |
-
[forwardlist.access]: #forwardlist.access
|
| 733 |
-
[forwardlist.cons]: #forwardlist.cons
|
| 734 |
-
[forwardlist.iter]: #forwardlist.iter
|
| 735 |
-
[forwardlist.modifiers]: #forwardlist.modifiers
|
| 736 |
-
[forwardlist.ops]: #forwardlist.ops
|
| 737 |
-
[forwardlist.overview]: #forwardlist.overview
|
| 738 |
-
[forwardlist.spec]: #forwardlist.spec
|
| 739 |
-
[hash.requirements]: library.md#hash.requirements
|
| 740 |
-
[iterator.requirements]: iterators.md#iterator.requirements
|
| 741 |
-
[iterator.requirements.general]: iterators.md#iterator.requirements.general
|
| 742 |
-
[list]: #list
|
| 743 |
-
[list.capacity]: #list.capacity
|
| 744 |
-
[list.cons]: #list.cons
|
| 745 |
-
[list.modifiers]: #list.modifiers
|
| 746 |
-
[list.ops]: #list.ops
|
| 747 |
-
[list.overview]: #list.overview
|
| 748 |
-
[list.special]: #list.special
|
| 749 |
-
[list.syn]: #list.syn
|
| 750 |
-
[map]: #map
|
| 751 |
-
[map.access]: #map.access
|
| 752 |
-
[map.cons]: #map.cons
|
| 753 |
-
[map.modifiers]: #map.modifiers
|
| 754 |
-
[map.overview]: #map.overview
|
| 755 |
-
[map.special]: #map.special
|
| 756 |
-
[multimap]: #multimap
|
| 757 |
-
[multimap.cons]: #multimap.cons
|
| 758 |
-
[multimap.modifiers]: #multimap.modifiers
|
| 759 |
-
[multimap.overview]: #multimap.overview
|
| 760 |
-
[multimap.special]: #multimap.special
|
| 761 |
-
[multiset]: #multiset
|
| 762 |
-
[multiset.cons]: #multiset.cons
|
| 763 |
-
[multiset.overview]: #multiset.overview
|
| 764 |
-
[multiset.special]: #multiset.special
|
| 765 |
-
[priority.queue]: #priority.queue
|
| 766 |
-
[priqueue.cons]: #priqueue.cons
|
| 767 |
-
[priqueue.cons.alloc]: #priqueue.cons.alloc
|
| 768 |
-
[priqueue.members]: #priqueue.members
|
| 769 |
-
[priqueue.special]: #priqueue.special
|
| 770 |
-
[queue]: #queue
|
| 771 |
-
[queue.cons]: #queue.cons
|
| 772 |
-
[queue.cons.alloc]: #queue.cons.alloc
|
| 773 |
-
[queue.defn]: #queue.defn
|
| 774 |
-
[queue.ops]: #queue.ops
|
| 775 |
-
[queue.special]: #queue.special
|
| 776 |
-
[queue.syn]: #queue.syn
|
| 777 |
-
[random.access.iterators]: iterators.md#random.access.iterators
|
| 778 |
-
[res.on.data.races]: library.md#res.on.data.races
|
| 779 |
-
[sequence.reqmts]: #sequence.reqmts
|
| 780 |
-
[sequences]: #sequences
|
| 781 |
-
[sequences.general]: #sequences.general
|
| 782 |
-
[set]: #set
|
| 783 |
-
[set.cons]: #set.cons
|
| 784 |
-
[set.overview]: #set.overview
|
| 785 |
-
[set.special]: #set.special
|
| 786 |
-
[stack]: #stack
|
| 787 |
-
[stack.cons]: #stack.cons
|
| 788 |
-
[stack.cons.alloc]: #stack.cons.alloc
|
| 789 |
-
[stack.defn]: #stack.defn
|
| 790 |
-
[stack.ops]: #stack.ops
|
| 791 |
-
[stack.special]: #stack.special
|
| 792 |
-
[stack.syn]: #stack.syn
|
| 793 |
-
[strings]: strings.md#strings
|
| 794 |
-
[swappable.requirements]: library.md#swappable.requirements
|
| 795 |
-
[tab:HashRequirements]: #tab:HashRequirements
|
| 796 |
-
[tab:containers.allocatoraware]: #tab:containers.allocatoraware
|
| 797 |
-
[tab:containers.associative.requirements]: #tab:containers.associative.requirements
|
| 798 |
-
[tab:containers.container.requirements]: #tab:containers.container.requirements
|
| 799 |
-
[tab:containers.lib.summary]: #tab:containers.lib.summary
|
| 800 |
-
[tab:containers.node.compat]: #tab:containers.node.compat
|
| 801 |
-
[tab:containers.optional.operations]: #tab:containers.optional.operations
|
| 802 |
-
[tab:containers.reversible.requirements]: #tab:containers.reversible.requirements
|
| 803 |
-
[tab:containers.sequence.optional]: #tab:containers.sequence.optional
|
| 804 |
-
[tab:containers.sequence.requirements]: #tab:containers.sequence.requirements
|
| 805 |
-
[temp.deduct]: temp.md#temp.deduct
|
| 806 |
-
[unord]: #unord
|
| 807 |
-
[unord.general]: #unord.general
|
| 808 |
-
[unord.hash]: utilities.md#unord.hash
|
| 809 |
-
[unord.map]: #unord.map
|
| 810 |
-
[unord.map.cnstr]: #unord.map.cnstr
|
| 811 |
-
[unord.map.elem]: #unord.map.elem
|
| 812 |
-
[unord.map.modifiers]: #unord.map.modifiers
|
| 813 |
-
[unord.map.overview]: #unord.map.overview
|
| 814 |
-
[unord.map.swap]: #unord.map.swap
|
| 815 |
-
[unord.map.syn]: #unord.map.syn
|
| 816 |
-
[unord.multimap]: #unord.multimap
|
| 817 |
-
[unord.multimap.cnstr]: #unord.multimap.cnstr
|
| 818 |
-
[unord.multimap.modifiers]: #unord.multimap.modifiers
|
| 819 |
-
[unord.multimap.overview]: #unord.multimap.overview
|
| 820 |
-
[unord.multimap.swap]: #unord.multimap.swap
|
| 821 |
-
[unord.multiset]: #unord.multiset
|
| 822 |
-
[unord.multiset.cnstr]: #unord.multiset.cnstr
|
| 823 |
-
[unord.multiset.overview]: #unord.multiset.overview
|
| 824 |
-
[unord.multiset.swap]: #unord.multiset.swap
|
| 825 |
-
[unord.req]: #unord.req
|
| 826 |
-
[unord.req.except]: #unord.req.except
|
| 827 |
-
[unord.set]: #unord.set
|
| 828 |
-
[unord.set.cnstr]: #unord.set.cnstr
|
| 829 |
-
[unord.set.overview]: #unord.set.overview
|
| 830 |
-
[unord.set.swap]: #unord.set.swap
|
| 831 |
-
[unord.set.syn]: #unord.set.syn
|
| 832 |
-
[vector]: #vector
|
| 833 |
-
[vector.bool]: #vector.bool
|
| 834 |
-
[vector.capacity]: #vector.capacity
|
| 835 |
-
[vector.cons]: #vector.cons
|
| 836 |
-
[vector.data]: #vector.data
|
| 837 |
-
[vector.modifiers]: #vector.modifiers
|
| 838 |
-
[vector.overview]: #vector.overview
|
| 839 |
-
[vector.special]: #vector.special
|
| 840 |
-
[vector.syn]: #vector.syn
|
| 841 |
-
|
| 842 |
-
[^1]: Equality comparison is a refinement of partitioning if no two
|
| 843 |
-
objects that compare equal fall into different partitions.
|
| 844 |
-
|
| 845 |
-
[^2]: These member functions are only provided by containers whose
|
| 846 |
-
iterators are random access iterators.
|
| 847 |
-
|
| 848 |
-
[^3]: As specified in [[allocator.requirements]], the requirements in
|
| 849 |
-
this Clause apply only to lists whose allocators compare equal.
|
| 850 |
-
|
| 851 |
-
[^4]: `reserve()` uses `Allocator::allocate()` which may throw an
|
| 852 |
-
appropriate exception.
|
|
|
|
| 33 |
`uses_allocator_v<Container, Allocator>` is `false`.
|
| 34 |
|
| 35 |
### Header `<queue>` synopsis <a id="queue.syn">[[queue.syn]]</a>
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
+
#include <compare> // see [compare.syn]
|
| 39 |
+
#include <initializer_list> // see [initializer.list.syn]
|
| 40 |
|
| 41 |
namespace std {
|
| 42 |
template<class T, class Container = deque<T>> class queue;
|
| 43 |
+
|
| 44 |
+
template<class T, class Container>
|
| 45 |
+
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 46 |
+
template<class T, class Container>
|
| 47 |
+
bool operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 48 |
+
template<class T, class Container>
|
| 49 |
+
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 50 |
+
template<class T, class Container>
|
| 51 |
+
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 52 |
+
template<class T, class Container>
|
| 53 |
+
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 54 |
+
template<class T, class Container>
|
| 55 |
+
bool operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 56 |
+
template<class T, three_way_comparable Container>
|
| 57 |
+
compare_three_way_result_t<Container>
|
| 58 |
+
operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 59 |
+
|
| 60 |
+
template<class T, class Container>
|
| 61 |
+
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 62 |
+
template<class T, class Container, class Alloc>
|
| 63 |
+
struct uses_allocator<queue<T, Container>, Alloc>;
|
| 64 |
+
|
| 65 |
template<class T, class Container = vector<T>,
|
| 66 |
class Compare = less<typename Container::value_type>>
|
| 67 |
class priority_queue;
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
template<class T, class Container, class Compare>
|
| 70 |
void swap(priority_queue<T, Container, Compare>& x,
|
| 71 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
| 72 |
+
template<class T, class Container, class Compare, class Alloc>
|
| 73 |
+
struct uses_allocator<priority_queue<T, Container, Compare>, Alloc>;
|
| 74 |
}
|
| 75 |
```
|
| 76 |
|
| 77 |
### Header `<stack>` synopsis <a id="stack.syn">[[stack.syn]]</a>
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
+
#include <compare> // see [compare.syn]
|
| 81 |
+
#include <initializer_list> // see [initializer.list.syn]
|
| 82 |
|
| 83 |
namespace std {
|
| 84 |
template<class T, class Container = deque<T>> class stack;
|
| 85 |
+
|
| 86 |
template<class T, class Container>
|
| 87 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
|
|
|
| 88 |
template<class T, class Container>
|
| 89 |
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 90 |
+
template<class T, class Container>
|
| 91 |
+
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 92 |
template<class T, class Container>
|
| 93 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
|
|
|
| 94 |
template<class T, class Container>
|
| 95 |
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 96 |
+
template<class T, class Container>
|
| 97 |
+
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 98 |
+
template<class T, three_way_comparable Container>
|
| 99 |
+
compare_three_way_result_t<Container>
|
| 100 |
+
operator<=>(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 101 |
+
|
| 102 |
template<class T, class Container>
|
| 103 |
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 104 |
+
template<class T, class Container, class Alloc>
|
| 105 |
+
struct uses_allocator<stack<T, Container>, Alloc>;
|
| 106 |
}
|
| 107 |
```
|
| 108 |
|
| 109 |
### Class template `queue` <a id="queue">[[queue]]</a>
|
| 110 |
|
| 111 |
+
#### Definition <a id="queue.defn">[[queue.defn]]</a>
|
| 112 |
|
| 113 |
Any sequence container supporting operations `front()`, `back()`,
|
| 114 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 115 |
+
particular, `list` [[list]] and `deque` [[deque]] can be used.
|
| 116 |
|
| 117 |
``` cpp
|
| 118 |
namespace std {
|
| 119 |
template<class T, class Container = deque<T>>
|
| 120 |
class queue {
|
|
|
|
| 127 |
|
| 128 |
protected:
|
| 129 |
Container c;
|
| 130 |
|
| 131 |
public:
|
| 132 |
+
queue() : queue(Container()) {}
|
| 133 |
explicit queue(const Container&);
|
| 134 |
+
explicit queue(Container&&);
|
| 135 |
template<class Alloc> explicit queue(const Alloc&);
|
| 136 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 137 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 138 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 139 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 140 |
|
| 141 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 142 |
size_type size() const { return c.size(); }
|
| 143 |
reference front() { return c.front(); }
|
| 144 |
const_reference front() const { return c.front(); }
|
| 145 |
reference back() { return c.back(); }
|
| 146 |
const_reference back() const { return c.back(); }
|
| 147 |
void push(const value_type& x) { c.push_back(x); }
|
| 148 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 149 |
template<class... Args>
|
| 150 |
+
decltype(auto) emplace(Args&&... args)
|
| 151 |
+
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 152 |
void pop() { c.pop_front(); }
|
| 153 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
| 154 |
{ using std::swap; swap(c, q.c); }
|
| 155 |
};
|
| 156 |
|
|
|
|
| 158 |
queue(Container) -> queue<typename Container::value_type, Container>;
|
| 159 |
|
| 160 |
template<class Container, class Allocator>
|
| 161 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
template<class T, class Container>
|
| 164 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 165 |
|
| 166 |
template<class T, class Container, class Alloc>
|
| 167 |
struct uses_allocator<queue<T, Container>, Alloc>
|
| 168 |
: uses_allocator<Container, Alloc>::type { };
|
| 169 |
}
|
| 170 |
```
|
| 171 |
|
| 172 |
+
#### Constructors <a id="queue.cons">[[queue.cons]]</a>
|
| 173 |
|
| 174 |
``` cpp
|
| 175 |
explicit queue(const Container& cont);
|
| 176 |
```
|
| 177 |
|
| 178 |
+
*Effects:* Initializes `c` with `cont`.
|
| 179 |
|
| 180 |
``` cpp
|
| 181 |
+
explicit queue(Container&& cont);
|
| 182 |
```
|
| 183 |
|
| 184 |
+
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 185 |
|
| 186 |
+
#### Constructors with allocators <a id="queue.cons.alloc">[[queue.cons.alloc]]</a>
|
| 187 |
|
| 188 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 189 |
in this subclause shall not participate in overload resolution.
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
template<class Alloc> explicit queue(const Alloc& a);
|
| 193 |
```
|
| 194 |
|
| 195 |
+
*Effects:* Initializes `c` with `a`.
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
template<class Alloc> queue(const container_type& cont, const Alloc& a);
|
| 199 |
```
|
| 200 |
|
| 201 |
+
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 202 |
the second argument.
|
| 203 |
|
| 204 |
``` cpp
|
| 205 |
template<class Alloc> queue(container_type&& cont, const Alloc& a);
|
| 206 |
```
|
| 207 |
|
| 208 |
+
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 209 |
and `a` as the second argument.
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
template<class Alloc> queue(const queue& q, const Alloc& a);
|
| 213 |
```
|
| 214 |
|
| 215 |
+
*Effects:* Initializes `c` with `q.c` as the first argument and `a` as
|
| 216 |
the second argument.
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
template<class Alloc> queue(queue&& q, const Alloc& a);
|
| 220 |
```
|
| 221 |
|
| 222 |
+
*Effects:* Initializes `c` with `std::move(q.c)` as the first argument
|
| 223 |
and `a` as the second argument.
|
| 224 |
|
| 225 |
+
#### Operators <a id="queue.ops">[[queue.ops]]</a>
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
template<class T, class Container>
|
| 229 |
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 230 |
```
|
|
|
|
| 243 |
bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 244 |
```
|
| 245 |
|
| 246 |
*Returns:* `x.c < y.c`.
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
``` cpp
|
| 249 |
template<class T, class Container>
|
| 250 |
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 251 |
```
|
| 252 |
|
| 253 |
*Returns:* `x.c > y.c`.
|
| 254 |
|
| 255 |
+
``` cpp
|
| 256 |
+
template<class T, class Container>
|
| 257 |
+
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
*Returns:* `x.c <= y.c`.
|
| 261 |
+
|
| 262 |
``` cpp
|
| 263 |
template<class T, class Container>
|
| 264 |
bool operator>=(const queue<T, Container>& x,
|
| 265 |
const queue<T, Container>& y);
|
| 266 |
```
|
| 267 |
|
| 268 |
*Returns:* `x.c >= y.c`.
|
| 269 |
|
| 270 |
+
``` cpp
|
| 271 |
+
template<class T, three_way_comparable Container>
|
| 272 |
+
compare_three_way_result_t<Container>
|
| 273 |
+
operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 274 |
+
```
|
| 275 |
+
|
| 276 |
+
*Returns:* `x.c <=> y.c`.
|
| 277 |
+
|
| 278 |
+
#### Specialized algorithms <a id="queue.special">[[queue.special]]</a>
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
template<class T, class Container>
|
| 282 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 283 |
```
|
| 284 |
|
| 285 |
+
*Constraints:* `is_swappable_v<Container>` is `true`.
|
|
|
|
| 286 |
|
| 287 |
*Effects:* As if by `x.swap(y)`.
|
| 288 |
|
| 289 |
### Class template `priority_queue` <a id="priority.queue">[[priority.queue]]</a>
|
| 290 |
|
| 291 |
+
#### Overview <a id="priqueue.overview">[[priqueue.overview]]</a>
|
| 292 |
+
|
| 293 |
Any sequence container with random access iterator and supporting
|
| 294 |
operations `front()`, `push_back()` and `pop_back()` can be used to
|
| 295 |
+
instantiate `priority_queue`. In particular, `vector` [[vector]] and
|
| 296 |
+
`deque` [[deque]] can be used. Instantiating `priority_queue` also
|
| 297 |
involves supplying a function or function object for making priority
|
| 298 |
comparisons; the library assumes that the function or function object
|
| 299 |
+
defines a strict weak ordering [[alg.sorting]].
|
| 300 |
|
| 301 |
``` cpp
|
| 302 |
namespace std {
|
| 303 |
template<class T, class Container = vector<T>,
|
| 304 |
class Compare = less<typename Container::value_type>>
|
|
|
|
| 314 |
protected:
|
| 315 |
Container c;
|
| 316 |
Compare comp;
|
| 317 |
|
| 318 |
public:
|
| 319 |
+
priority_queue() : priority_queue(Compare()) {}
|
| 320 |
+
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
|
| 321 |
priority_queue(const Compare& x, const Container&);
|
| 322 |
+
priority_queue(const Compare& x, Container&&);
|
| 323 |
template<class InputIterator>
|
| 324 |
+
priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 325 |
+
const Container&);
|
| 326 |
template<class InputIterator>
|
| 327 |
priority_queue(InputIterator first, InputIterator last,
|
| 328 |
const Compare& x = Compare(), Container&& = Container());
|
| 329 |
template<class Alloc> explicit priority_queue(const Alloc&);
|
| 330 |
template<class Alloc> priority_queue(const Compare&, const Alloc&);
|
| 331 |
template<class Alloc> priority_queue(const Compare&, const Container&, const Alloc&);
|
| 332 |
template<class Alloc> priority_queue(const Compare&, Container&&, const Alloc&);
|
| 333 |
template<class Alloc> priority_queue(const priority_queue&, const Alloc&);
|
| 334 |
template<class Alloc> priority_queue(priority_queue&&, const Alloc&);
|
| 335 |
|
| 336 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 337 |
size_type size() const { return c.size(); }
|
| 338 |
const_reference top() const { return c.front(); }
|
| 339 |
void push(const value_type& x);
|
| 340 |
void push(value_type&& x);
|
| 341 |
template<class... Args> void emplace(Args&&... args);
|
|
|
|
| 369 |
struct uses_allocator<priority_queue<T, Container, Compare>, Alloc>
|
| 370 |
: uses_allocator<Container, Alloc>::type { };
|
| 371 |
}
|
| 372 |
```
|
| 373 |
|
| 374 |
+
#### Constructors <a id="priqueue.cons">[[priqueue.cons]]</a>
|
| 375 |
|
| 376 |
``` cpp
|
| 377 |
priority_queue(const Compare& x, const Container& y);
|
| 378 |
+
priority_queue(const Compare& x, Container&& y);
|
| 379 |
```
|
| 380 |
|
| 381 |
+
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 382 |
|
| 383 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 384 |
constructing or move constructing as appropriate); calls
|
| 385 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 386 |
|
| 387 |
``` cpp
|
| 388 |
template<class InputIterator>
|
| 389 |
+
priority_queue(InputIterator first, InputIterator last, const Compare& x, const Container& y);
|
|
|
|
|
|
|
| 390 |
template<class InputIterator>
|
| 391 |
+
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare(),
|
|
|
|
| 392 |
Container&& y = Container());
|
| 393 |
```
|
| 394 |
|
| 395 |
+
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 396 |
|
| 397 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 398 |
constructing or move constructing as appropriate); calls
|
| 399 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 400 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 401 |
|
| 402 |
+
#### Constructors with allocators <a id="priqueue.cons.alloc">[[priqueue.cons.alloc]]</a>
|
| 403 |
|
| 404 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 405 |
in this subclause shall not participate in overload resolution.
|
| 406 |
|
| 407 |
``` cpp
|
| 408 |
template<class Alloc> explicit priority_queue(const Alloc& a);
|
| 409 |
```
|
| 410 |
|
| 411 |
+
*Effects:* Initializes `c` with `a` and value-initializes `comp`.
|
| 412 |
|
| 413 |
``` cpp
|
| 414 |
template<class Alloc> priority_queue(const Compare& compare, const Alloc& a);
|
| 415 |
```
|
| 416 |
|
| 417 |
+
*Effects:* Initializes `c` with `a` and initializes `comp` with
|
| 418 |
`compare`.
|
| 419 |
|
| 420 |
``` cpp
|
| 421 |
template<class Alloc>
|
| 422 |
priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
|
| 423 |
```
|
| 424 |
|
| 425 |
+
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 426 |
the second argument, and initializes `comp` with `compare`; calls
|
| 427 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 428 |
|
| 429 |
``` cpp
|
| 430 |
template<class Alloc>
|
| 431 |
priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
|
| 432 |
```
|
| 433 |
|
| 434 |
+
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 435 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 436 |
calls `make_heap(c.begin(), c.end(), comp)`.
|
| 437 |
|
| 438 |
``` cpp
|
| 439 |
template<class Alloc> priority_queue(const priority_queue& q, const Alloc& a);
|
| 440 |
```
|
| 441 |
|
| 442 |
+
*Effects:* Initializes `c` with `q.c` as the first argument and `a` as
|
| 443 |
the second argument, and initializes `comp` with `q.comp`.
|
| 444 |
|
| 445 |
``` cpp
|
| 446 |
template<class Alloc> priority_queue(priority_queue&& q, const Alloc& a);
|
| 447 |
```
|
| 448 |
|
| 449 |
+
*Effects:* Initializes `c` with `std::move(q.c)` as the first argument
|
| 450 |
and `a` as the second argument, and initializes `comp` with
|
| 451 |
`std::move(q.comp)`.
|
| 452 |
|
| 453 |
+
#### Members <a id="priqueue.members">[[priqueue.members]]</a>
|
| 454 |
|
| 455 |
``` cpp
|
| 456 |
void push(const value_type& x);
|
| 457 |
```
|
| 458 |
|
|
|
|
| 473 |
c.push_back(std::move(x));
|
| 474 |
push_heap(c.begin(), c.end(), comp);
|
| 475 |
```
|
| 476 |
|
| 477 |
``` cpp
|
| 478 |
+
template<class... Args> void emplace(Args&&... args);
|
| 479 |
```
|
| 480 |
|
| 481 |
*Effects:* As if by:
|
| 482 |
|
| 483 |
``` cpp
|
|
|
|
| 494 |
``` cpp
|
| 495 |
pop_heap(c.begin(), c.end(), comp);
|
| 496 |
c.pop_back();
|
| 497 |
```
|
| 498 |
|
| 499 |
+
#### Specialized algorithms <a id="priqueue.special">[[priqueue.special]]</a>
|
| 500 |
|
| 501 |
``` cpp
|
| 502 |
template<class T, class Container, class Compare>
|
| 503 |
void swap(priority_queue<T, Container, Compare>& x,
|
| 504 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
| 505 |
```
|
| 506 |
|
| 507 |
+
*Constraints:* `is_swappable_v<Container>` is `true` and
|
|
|
|
| 508 |
`is_swappable_v<Compare>` is `true`.
|
| 509 |
|
| 510 |
*Effects:* As if by `x.swap(y)`.
|
| 511 |
|
| 512 |
### Class template `stack` <a id="stack">[[stack]]</a>
|
| 513 |
|
| 514 |
Any sequence container supporting operations `back()`, `push_back()` and
|
| 515 |
+
`pop_back()` can be used to instantiate `stack`. In particular, `vector`
|
| 516 |
+
[[vector]], `list` [[list]] and `deque` [[deque]] can be used.
|
|
|
|
| 517 |
|
| 518 |
+
#### Definition <a id="stack.defn">[[stack.defn]]</a>
|
| 519 |
|
| 520 |
``` cpp
|
| 521 |
namespace std {
|
| 522 |
template<class T, class Container = deque<T>>
|
| 523 |
class stack {
|
|
|
|
| 530 |
|
| 531 |
protected:
|
| 532 |
Container c;
|
| 533 |
|
| 534 |
public:
|
| 535 |
+
stack() : stack(Container()) {}
|
| 536 |
explicit stack(const Container&);
|
| 537 |
+
explicit stack(Container&&);
|
| 538 |
template<class Alloc> explicit stack(const Alloc&);
|
| 539 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 540 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 541 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 542 |
template<class Alloc> stack(stack&&, const Alloc&);
|
| 543 |
|
| 544 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 545 |
size_type size() const { return c.size(); }
|
| 546 |
reference top() { return c.back(); }
|
| 547 |
const_reference top() const { return c.back(); }
|
| 548 |
void push(const value_type& x) { c.push_back(x); }
|
| 549 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 550 |
template<class... Args>
|
| 551 |
+
decltype(auto) emplace(Args&&... args)
|
| 552 |
+
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 553 |
void pop() { c.pop_back(); }
|
| 554 |
void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
|
| 555 |
{ using std::swap; swap(c, s.c); }
|
| 556 |
};
|
| 557 |
|
|
|
|
| 559 |
stack(Container) -> stack<typename Container::value_type, Container>;
|
| 560 |
|
| 561 |
template<class Container, class Allocator>
|
| 562 |
stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
|
| 563 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
template<class T, class Container, class Alloc>
|
| 565 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 566 |
: uses_allocator<Container, Alloc>::type { };
|
| 567 |
}
|
| 568 |
```
|
| 569 |
|
| 570 |
+
#### Constructors <a id="stack.cons">[[stack.cons]]</a>
|
| 571 |
|
| 572 |
``` cpp
|
| 573 |
explicit stack(const Container& cont);
|
| 574 |
```
|
| 575 |
|
| 576 |
*Effects:* Initializes `c` with `cont`.
|
| 577 |
|
| 578 |
``` cpp
|
| 579 |
+
explicit stack(Container&& cont);
|
| 580 |
```
|
| 581 |
|
| 582 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 583 |
|
| 584 |
+
#### Constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
|
| 585 |
|
| 586 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 587 |
in this subclause shall not participate in overload resolution.
|
| 588 |
|
| 589 |
``` cpp
|
| 590 |
template<class Alloc> explicit stack(const Alloc& a);
|
| 591 |
```
|
| 592 |
|
| 593 |
+
*Effects:* Initializes `c` with `a`.
|
| 594 |
|
| 595 |
``` cpp
|
| 596 |
template<class Alloc> stack(const container_type& cont, const Alloc& a);
|
| 597 |
```
|
| 598 |
|
| 599 |
+
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 600 |
the second argument.
|
| 601 |
|
| 602 |
``` cpp
|
| 603 |
template<class Alloc> stack(container_type&& cont, const Alloc& a);
|
| 604 |
```
|
| 605 |
|
| 606 |
+
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 607 |
and `a` as the second argument.
|
| 608 |
|
| 609 |
``` cpp
|
| 610 |
template<class Alloc> stack(const stack& s, const Alloc& a);
|
| 611 |
```
|
| 612 |
|
| 613 |
+
*Effects:* Initializes `c` with `s.c` as the first argument and `a` as
|
| 614 |
the second argument.
|
| 615 |
|
| 616 |
``` cpp
|
| 617 |
template<class Alloc> stack(stack&& s, const Alloc& a);
|
| 618 |
```
|
| 619 |
|
| 620 |
+
*Effects:* Initializes `c` with `std::move(s.c)` as the first argument
|
| 621 |
and `a` as the second argument.
|
| 622 |
|
| 623 |
+
#### Operators <a id="stack.ops">[[stack.ops]]</a>
|
| 624 |
|
| 625 |
``` cpp
|
| 626 |
template<class T, class Container>
|
| 627 |
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 628 |
```
|
|
|
|
| 641 |
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 642 |
```
|
| 643 |
|
| 644 |
*Returns:* `x.c < y.c`.
|
| 645 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
``` cpp
|
| 647 |
template<class T, class Container>
|
| 648 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 649 |
```
|
| 650 |
|
| 651 |
*Returns:* `x.c > y.c`.
|
| 652 |
|
| 653 |
+
``` cpp
|
| 654 |
+
template<class T, class Container>
|
| 655 |
+
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 656 |
+
```
|
| 657 |
+
|
| 658 |
+
*Returns:* `x.c <= y.c`.
|
| 659 |
+
|
| 660 |
``` cpp
|
| 661 |
template<class T, class Container>
|
| 662 |
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 663 |
```
|
| 664 |
|
| 665 |
*Returns:* `x.c >= y.c`.
|
| 666 |
|
| 667 |
+
``` cpp
|
| 668 |
+
template<class T, three_way_comparable Container>
|
| 669 |
+
compare_three_way_result_t<Container>
|
| 670 |
+
operator<=>(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 671 |
+
```
|
| 672 |
+
|
| 673 |
+
*Returns:* `x.c <=> y.c`.
|
| 674 |
+
|
| 675 |
+
#### Specialized algorithms <a id="stack.special">[[stack.special]]</a>
|
| 676 |
|
| 677 |
``` cpp
|
| 678 |
template<class T, class Container>
|
| 679 |
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 680 |
```
|
| 681 |
|
| 682 |
+
*Constraints:* `is_swappable_v<Container>` is `true`.
|
|
|
|
| 683 |
|
| 684 |
*Effects:* As if by `x.swap(y)`.
|
| 685 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|