| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#ifndef _FORWARD_LIST_H |
| 31 |
#define _FORWARD_LIST_H 1 |
| 32 |
|
| 33 |
#ifdef _GLIBCXX_SYSHDR |
| 34 |
#pragma GCC system_header |
| 35 |
#endif |
| 36 |
|
| 37 |
#include <initializer_list> |
| 38 |
#include <bits/stl_iterator_base_types.h> |
| 39 |
#include <bits/stl_iterator.h> |
| 40 |
#include <bits/stl_algobase.h> |
| 41 |
#include <bits/stl_function.h> |
| 42 |
#include <bits/allocator.h> |
| 43 |
#include <bits/allocated_ptr.h> |
| 44 |
#include <bits/ptr_traits.h> |
| 45 |
#include <debug/assertions.h> |
| 46 |
#include <ext/alloc_traits.h> |
| 47 |
#include <ext/aligned_buffer.h> |
| 48 |
#include <debug/assertions.h> |
| 49 |
#if __glibcxx_containers_ranges |
| 50 |
# include <bits/ranges_base.h> |
| 51 |
# include <bits/ranges_util.h> |
| 52 |
#endif |
| 53 |
|
| 54 |
#if ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 55 |
# define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST 1 |
| 56 |
#endif |
| 57 |
|
| 58 |
namespace std _GLIBCXX_VISIBILITY(default) |
| 59 |
{ |
| 60 |
_GLIBCXX_BEGIN_NAMESPACE_VERSION |
| 61 |
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
struct _Fwd_list_node_base |
| 70 |
{ |
| 71 |
using _Base_ptr = _Fwd_list_node_base*; |
| 72 |
|
| 73 |
_Fwd_list_node_base() = default; |
| 74 |
_Fwd_list_node_base(_Fwd_list_node_base&& __x) noexcept |
| 75 |
: _M_next(__x._M_next) |
| 76 |
{ __x._M_next = nullptr; } |
| 77 |
|
| 78 |
_Fwd_list_node_base(const _Fwd_list_node_base&) = delete; |
| 79 |
_Fwd_list_node_base& operator=(const _Fwd_list_node_base&) = delete; |
| 80 |
|
| 81 |
_Fwd_list_node_base& |
| 82 |
operator=(_Fwd_list_node_base&& __x) noexcept |
| 83 |
{ |
| 84 |
_M_next = __x._M_next; |
| 85 |
__x._M_next = nullptr; |
| 86 |
return *this; |
| 87 |
} |
| 88 |
|
| 89 |
_Fwd_list_node_base* _M_next = nullptr; |
| 90 |
|
| 91 |
_Fwd_list_node_base* |
| 92 |
_M_transfer_after(_Fwd_list_node_base* __begin, |
| 93 |
_Fwd_list_node_base* __end) noexcept |
| 94 |
{ |
| 95 |
_Fwd_list_node_base* __keep = __begin->_M_next; |
| 96 |
if (__end) |
| 97 |
{ |
| 98 |
__begin->_M_next = __end->_M_next; |
| 99 |
__end->_M_next = _M_next; |
| 100 |
} |
| 101 |
else |
| 102 |
__begin->_M_next = nullptr; |
| 103 |
_M_next = __keep; |
| 104 |
return __end; |
| 105 |
} |
| 106 |
|
| 107 |
void |
| 108 |
_M_reverse_after() noexcept |
| 109 |
{ |
| 110 |
_Fwd_list_node_base* __tail = _M_next; |
| 111 |
if (!__tail) |
| 112 |
return; |
| 113 |
while (_Fwd_list_node_base* __temp = __tail->_M_next) |
| 114 |
{ |
| 115 |
_Fwd_list_node_base* __keep = _M_next; |
| 116 |
_M_next = __temp; |
| 117 |
__tail->_M_next = __temp->_M_next; |
| 118 |
_M_next->_M_next = __keep; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
_Fwd_list_node_base* _M_base_ptr() { return this; } |
| 123 |
const _Fwd_list_node_base* _M_base_ptr() const { return this; } |
| 124 |
}; |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
template<typename _Tp> |
| 133 |
struct _Fwd_list_node |
| 134 |
: public _Fwd_list_node_base |
| 135 |
{ |
| 136 |
using _Node_ptr = _Fwd_list_node*; |
| 137 |
|
| 138 |
_Fwd_list_node() = default; |
| 139 |
|
| 140 |
__gnu_cxx::__aligned_buffer<_Tp> _M_storage; |
| 141 |
|
| 142 |
_Tp* |
| 143 |
_M_valptr() noexcept |
| 144 |
{ return _M_storage._M_ptr(); } |
| 145 |
|
| 146 |
const _Tp* |
| 147 |
_M_valptr() const noexcept |
| 148 |
{ return _M_storage._M_ptr(); } |
| 149 |
|
| 150 |
_Node_ptr |
| 151 |
_M_node_ptr() |
| 152 |
{ return this; } |
| 153 |
}; |
| 154 |
|
| 155 |
template<typename _Tp> struct _Fwd_list_const_iterator; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
template<typename _Tp> |
| 163 |
struct _Fwd_list_iterator |
| 164 |
{ |
| 165 |
typedef _Fwd_list_iterator<_Tp> _Self; |
| 166 |
typedef _Fwd_list_node<_Tp> _Node; |
| 167 |
|
| 168 |
typedef _Tp value_type; |
| 169 |
typedef _Tp* pointer; |
| 170 |
typedef _Tp& reference; |
| 171 |
typedef ptrdiff_t difference_type; |
| 172 |
typedef std::forward_iterator_tag iterator_category; |
| 173 |
|
| 174 |
_Fwd_list_iterator() noexcept |
| 175 |
: _M_node() { } |
| 176 |
|
| 177 |
explicit |
| 178 |
_Fwd_list_iterator(_Fwd_list_node_base* __n) noexcept |
| 179 |
: _M_node(__n) { } |
| 180 |
|
| 181 |
[[__nodiscard__]] |
| 182 |
reference |
| 183 |
operator*() const noexcept |
| 184 |
{ return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } |
| 185 |
|
| 186 |
[[__nodiscard__]] |
| 187 |
pointer |
| 188 |
operator->() const noexcept |
| 189 |
{ return static_cast<_Node*>(this->_M_node)->_M_valptr(); } |
| 190 |
|
| 191 |
_Self& |
| 192 |
operator++() noexcept |
| 193 |
{ |
| 194 |
_M_node = _M_node->_M_next; |
| 195 |
return *this; |
| 196 |
} |
| 197 |
|
| 198 |
_Self |
| 199 |
operator++(int) noexcept |
| 200 |
{ |
| 201 |
_Self __tmp(*this); |
| 202 |
_M_node = _M_node->_M_next; |
| 203 |
return __tmp; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
[[__nodiscard__]] |
| 210 |
friend bool |
| 211 |
operator==(const _Self& __x, const _Self& __y) noexcept |
| 212 |
{ return __x._M_node == __y._M_node; } |
| 213 |
|
| 214 |
#if __cpp_impl_three_way_comparison < 201907L |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
[[__nodiscard__]] |
| 219 |
friend bool |
| 220 |
operator!=(const _Self& __x, const _Self& __y) noexcept |
| 221 |
{ return __x._M_node != __y._M_node; } |
| 222 |
#endif |
| 223 |
|
| 224 |
private: |
| 225 |
template<typename, typename> |
| 226 |
friend class forward_list; |
| 227 |
template<typename, typename> |
| 228 |
friend struct _Fwd_list_base; |
| 229 |
friend struct _Fwd_list_const_iterator<_Tp>; |
| 230 |
|
| 231 |
_Self |
| 232 |
_M_next() const noexcept |
| 233 |
{ |
| 234 |
if (_M_node) |
| 235 |
return _Fwd_list_iterator(_M_node->_M_next); |
| 236 |
else |
| 237 |
return _Fwd_list_iterator(nullptr); |
| 238 |
} |
| 239 |
|
| 240 |
_Fwd_list_node_base* _M_node; |
| 241 |
}; |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
template<typename _Tp> |
| 249 |
struct _Fwd_list_const_iterator |
| 250 |
{ |
| 251 |
typedef _Fwd_list_const_iterator<_Tp> _Self; |
| 252 |
typedef const _Fwd_list_node<_Tp> _Node; |
| 253 |
typedef _Fwd_list_iterator<_Tp> iterator; |
| 254 |
|
| 255 |
typedef _Tp value_type; |
| 256 |
typedef const _Tp* pointer; |
| 257 |
typedef const _Tp& reference; |
| 258 |
typedef ptrdiff_t difference_type; |
| 259 |
typedef std::forward_iterator_tag iterator_category; |
| 260 |
|
| 261 |
_Fwd_list_const_iterator() noexcept |
| 262 |
: _M_node() { } |
| 263 |
|
| 264 |
explicit |
| 265 |
_Fwd_list_const_iterator(const _Fwd_list_node_base* __n) noexcept |
| 266 |
: _M_node(__n) { } |
| 267 |
|
| 268 |
_Fwd_list_const_iterator(const iterator& __iter) noexcept |
| 269 |
: _M_node(__iter._M_node) { } |
| 270 |
|
| 271 |
[[__nodiscard__]] |
| 272 |
reference |
| 273 |
operator*() const noexcept |
| 274 |
{ return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } |
| 275 |
|
| 276 |
[[__nodiscard__]] |
| 277 |
pointer |
| 278 |
operator->() const noexcept |
| 279 |
{ return static_cast<_Node*>(this->_M_node)->_M_valptr(); } |
| 280 |
|
| 281 |
_Self& |
| 282 |
operator++() noexcept |
| 283 |
{ |
| 284 |
_M_node = _M_node->_M_next; |
| 285 |
return *this; |
| 286 |
} |
| 287 |
|
| 288 |
_Self |
| 289 |
operator++(int) noexcept |
| 290 |
{ |
| 291 |
_Self __tmp(*this); |
| 292 |
_M_node = _M_node->_M_next; |
| 293 |
return __tmp; |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
[[__nodiscard__]] |
| 300 |
friend bool |
| 301 |
operator==(const _Self& __x, const _Self& __y) noexcept |
| 302 |
{ return __x._M_node == __y._M_node; } |
| 303 |
|
| 304 |
#if __cpp_impl_three_way_comparison < 201907L |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
[[__nodiscard__]] |
| 309 |
friend bool |
| 310 |
operator!=(const _Self& __x, const _Self& __y) noexcept |
| 311 |
{ return __x._M_node != __y._M_node; } |
| 312 |
#endif |
| 313 |
|
| 314 |
private: |
| 315 |
template<typename, typename> |
| 316 |
friend class forward_list; |
| 317 |
template<typename, typename> |
| 318 |
friend struct _Fwd_list_base; |
| 319 |
|
| 320 |
_Self |
| 321 |
_M_next() const noexcept |
| 322 |
{ |
| 323 |
if (this->_M_node) |
| 324 |
return _Fwd_list_const_iterator(_M_node->_M_next); |
| 325 |
else |
| 326 |
return _Fwd_list_const_iterator(nullptr); |
| 327 |
} |
| 328 |
|
| 329 |
_Fwd_list_iterator<_Tp> |
| 330 |
_M_const_cast() const noexcept |
| 331 |
{ |
| 332 |
return _Fwd_list_iterator<_Tp>( |
| 333 |
const_cast<_Fwd_list_node_base*>(_M_node)); |
| 334 |
} |
| 335 |
|
| 336 |
const _Fwd_list_node_base* _M_node; |
| 337 |
}; |
| 338 |
|
| 339 |
template<typename _Tp, typename _Allocator> class forward_list; |
| 340 |
template<typename _Tp, typename _Allocator> struct _Fwd_list_base; |
| 341 |
|
| 342 |
namespace __fwdlist |
| 343 |
{ |
| 344 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 345 |
|
| 346 |
template<typename _VoidPtr> |
| 347 |
struct _Node_base |
| 348 |
{ |
| 349 |
using _Base_ptr = __ptr_rebind<_VoidPtr, _Node_base>; |
| 350 |
|
| 351 |
_Node_base() = default; |
| 352 |
|
| 353 |
_Node_base(_Node_base&& __x) noexcept |
| 354 |
: _M_next(__x._M_next) |
| 355 |
{ __x._M_next = nullptr; } |
| 356 |
|
| 357 |
_Node_base(const _Node_base&) = delete; |
| 358 |
_Node_base& operator=(const _Node_base&) = delete; |
| 359 |
|
| 360 |
_Node_base& |
| 361 |
operator=(_Node_base&& __x) noexcept |
| 362 |
{ |
| 363 |
_M_next = __x._M_next; |
| 364 |
__x._M_next = nullptr; |
| 365 |
return *this; |
| 366 |
} |
| 367 |
|
| 368 |
_Base_ptr _M_next = nullptr; |
| 369 |
|
| 370 |
|
| 371 |
_Base_ptr |
| 372 |
_M_transfer_after(_Base_ptr __begin, _Base_ptr __end) noexcept |
| 373 |
{ |
| 374 |
_Base_ptr __keep = __begin->_M_next; |
| 375 |
if (__end) |
| 376 |
{ |
| 377 |
__begin->_M_next = __end->_M_next; |
| 378 |
__end->_M_next = _M_next; |
| 379 |
} |
| 380 |
else |
| 381 |
__begin->_M_next = nullptr; |
| 382 |
_M_next = __keep; |
| 383 |
return __end; |
| 384 |
} |
| 385 |
|
| 386 |
void |
| 387 |
_M_reverse_after() noexcept |
| 388 |
{ |
| 389 |
_Base_ptr __tail = _M_next; |
| 390 |
if (!__tail) |
| 391 |
return; |
| 392 |
while (_Base_ptr __temp = __tail->_M_next) |
| 393 |
{ |
| 394 |
_Base_ptr __keep = _M_next; |
| 395 |
_M_next = __temp; |
| 396 |
__tail->_M_next = __temp->_M_next; |
| 397 |
_M_next->_M_next = __keep; |
| 398 |
} |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
_Base_ptr |
| 406 |
_M_base_ptr() const |
| 407 |
{ |
| 408 |
return pointer_traits<_Base_ptr>:: |
| 409 |
pointer_to(const_cast<_Node_base&>(*this)); |
| 410 |
} |
| 411 |
}; |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
template<typename _ValPtr> |
| 417 |
struct _Node |
| 418 |
: public _Node_base<__ptr_rebind<_ValPtr, void>> |
| 419 |
{ |
| 420 |
using value_type = typename pointer_traits<_ValPtr>::element_type; |
| 421 |
using _Node_ptr = __ptr_rebind<_ValPtr, _Node>; |
| 422 |
|
| 423 |
_Node() noexcept { } |
| 424 |
~_Node() { } |
| 425 |
_Node(_Node&&) = delete; |
| 426 |
|
| 427 |
union _Uninit_storage |
| 428 |
{ |
| 429 |
_Uninit_storage() noexcept { } |
| 430 |
~_Uninit_storage() { } |
| 431 |
|
| 432 |
#if ! _GLIBCXX_INLINE_VERSION |
| 433 |
|
| 434 |
alignas(__alignof__(value_type)) |
| 435 |
#endif |
| 436 |
value_type _M_data; |
| 437 |
}; |
| 438 |
_Uninit_storage _M_u; |
| 439 |
|
| 440 |
value_type* |
| 441 |
_M_valptr() noexcept |
| 442 |
{ return std::__addressof(_M_u._M_data); } |
| 443 |
|
| 444 |
const value_type* |
| 445 |
_M_valptr() const noexcept |
| 446 |
{ return std::__addressof(_M_u._M_data); } |
| 447 |
|
| 448 |
_Node_ptr |
| 449 |
_M_node_ptr() |
| 450 |
{ return pointer_traits<_Node_ptr>::pointer_to(*this); } |
| 451 |
}; |
| 452 |
|
| 453 |
|
| 454 |
template<bool _Const, typename _Ptr> |
| 455 |
class _Iterator |
| 456 |
{ |
| 457 |
using _Node = __fwdlist::_Node<_Ptr>; |
| 458 |
using _Base_ptr |
| 459 |
= typename __fwdlist::_Node_base<__ptr_rebind<_Ptr, void>>::_Base_ptr; |
| 460 |
|
| 461 |
template<typename _Tp> |
| 462 |
using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>; |
| 463 |
|
| 464 |
public: |
| 465 |
using value_type = typename pointer_traits<_Ptr>::element_type; |
| 466 |
using difference_type = ptrdiff_t; |
| 467 |
using iterator_category = forward_iterator_tag; |
| 468 |
using pointer = __maybe_const<value_type>*; |
| 469 |
using reference = __maybe_const<value_type>&; |
| 470 |
|
| 471 |
constexpr _Iterator() noexcept : _M_node() { } |
| 472 |
|
| 473 |
_Iterator(const _Iterator&) = default; |
| 474 |
_Iterator& operator=(const _Iterator&) = default; |
| 475 |
|
| 476 |
#ifdef __glibcxx_concepts |
| 477 |
constexpr |
| 478 |
_Iterator(const _Iterator<false, _Ptr>& __i) requires _Const |
| 479 |
#else |
| 480 |
template<bool _OtherConst, |
| 481 |
typename = __enable_if_t<_Const && !_OtherConst>> |
| 482 |
constexpr |
| 483 |
_Iterator(const _Iterator<_OtherConst, _Ptr>& __i) |
| 484 |
#endif |
| 485 |
: _M_node(__i._M_node) { } |
| 486 |
|
| 487 |
constexpr explicit |
| 488 |
_Iterator(_Base_ptr __x) noexcept |
| 489 |
: _M_node(__x) { } |
| 490 |
|
| 491 |
[[__nodiscard__]] |
| 492 |
constexpr reference |
| 493 |
operator*() const noexcept |
| 494 |
{ return static_cast<_Node&>(*this->_M_node)._M_u._M_data; } |
| 495 |
|
| 496 |
[[__nodiscard__]] |
| 497 |
constexpr pointer |
| 498 |
operator->() const noexcept |
| 499 |
{ return static_cast<_Node&>(*this->_M_node)._M_valptr(); } |
| 500 |
|
| 501 |
_GLIBCXX14_CONSTEXPR _Iterator& |
| 502 |
operator++() noexcept |
| 503 |
{ |
| 504 |
_M_node = _M_node->_M_next; |
| 505 |
return *this; |
| 506 |
} |
| 507 |
|
| 508 |
_GLIBCXX14_CONSTEXPR _Iterator |
| 509 |
operator++(int) noexcept |
| 510 |
{ |
| 511 |
_Iterator __tmp(*this); |
| 512 |
_M_node = _M_node->_M_next; |
| 513 |
return __tmp; |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
[[__nodiscard__]] |
| 520 |
friend constexpr bool |
| 521 |
operator==(const _Iterator& __x, const _Iterator& __y) noexcept |
| 522 |
{ return __x._M_node == __y._M_node; } |
| 523 |
|
| 524 |
#if __cpp_impl_three_way_comparison < 201907L |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
[[__nodiscard__]] |
| 529 |
friend constexpr bool |
| 530 |
operator!=(const _Iterator& __x, const _Iterator& __y) noexcept |
| 531 |
{ return __x._M_node != __y._M_node; } |
| 532 |
#endif |
| 533 |
|
| 534 |
private: |
| 535 |
template<typename _Tp, typename _Allocator> |
| 536 |
friend class _GLIBCXX_STD_C::forward_list; |
| 537 |
template<typename _Tp, typename _Allocator> |
| 538 |
friend struct _GLIBCXX_STD_C::_Fwd_list_base; |
| 539 |
|
| 540 |
constexpr _Iterator<false, _Ptr> |
| 541 |
_M_const_cast() const noexcept |
| 542 |
{ return _Iterator<false, _Ptr>(_M_node); } |
| 543 |
|
| 544 |
friend _Iterator<!_Const, _Ptr>; |
| 545 |
|
| 546 |
constexpr _Iterator |
| 547 |
_M_next() const noexcept |
| 548 |
{ return _Iterator(_M_node ? _M_node->_M_next : nullptr); } |
| 549 |
|
| 550 |
_Base_ptr _M_node; |
| 551 |
}; |
| 552 |
#endif |
| 553 |
|
| 554 |
|
| 555 |
template<typename _Tp, typename _Ptr> |
| 556 |
struct _Node_traits; |
| 557 |
|
| 558 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_LIST <= 9000 |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
template<typename _Tp> |
| 563 |
struct _Node_traits<_Tp, _Tp*> |
| 564 |
{ |
| 565 |
using _Node_base = _Fwd_list_node_base; |
| 566 |
using _Node = _Fwd_list_node<_Tp>; |
| 567 |
using _Iterator = _Fwd_list_iterator<_Tp>; |
| 568 |
using _Const_iterator = _Fwd_list_const_iterator<_Tp>; |
| 569 |
}; |
| 570 |
#endif |
| 571 |
|
| 572 |
#if ! _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 573 |
|
| 574 |
template<typename _Tp, typename _Ptr> |
| 575 |
struct _Node_traits |
| 576 |
: _Node_traits<_Tp, _Tp*> |
| 577 |
{ }; |
| 578 |
#else |
| 579 |
|
| 580 |
template<typename _Tp, typename _Ptr> |
| 581 |
struct _Node_traits |
| 582 |
{ |
| 583 |
private: |
| 584 |
using _VoidPtr = __ptr_rebind<_Ptr, void>; |
| 585 |
using _ValPtr = __ptr_rebind<_Ptr, _Tp>; |
| 586 |
|
| 587 |
public: |
| 588 |
using _Node_base = __fwdlist::_Node_base<_VoidPtr>; |
| 589 |
using _Node = __fwdlist::_Node<_ValPtr>; |
| 590 |
using _Iterator = __fwdlist::_Iterator<false, _ValPtr>; |
| 591 |
using _Const_iterator = __fwdlist::_Iterator<true, _ValPtr>; |
| 592 |
}; |
| 593 |
#endif |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
template<typename _Tp, typename _Alloc> |
| 600 |
struct _Fwd_list_base |
| 601 |
{ |
| 602 |
#if __cplusplus > 201703L || defined __STRICT_ANSI__ |
| 603 |
|
| 604 |
using pointer = typename allocator_traits<_Alloc>::pointer; |
| 605 |
#else |
| 606 |
using _Tp_alloc_traits |
| 607 |
= typename allocator_traits<_Alloc>::template rebind_traits<_Tp>; |
| 608 |
using pointer = typename _Tp_alloc_traits::pointer; |
| 609 |
#endif |
| 610 |
|
| 611 |
protected: |
| 612 |
using _Node_traits = __fwdlist::_Node_traits<_Tp, pointer>; |
| 613 |
using _Node = typename _Node_traits::_Node; |
| 614 |
using _Node_alloc_type = __alloc_rebind<_Alloc, _Node>; |
| 615 |
using _Node_alloc_traits = __gnu_cxx::__alloc_traits<_Node_alloc_type>; |
| 616 |
using _Node_ptr = typename _Node_alloc_traits::pointer; |
| 617 |
using _Base_ptr = typename _Node_traits::_Node_base::_Base_ptr; |
| 618 |
|
| 619 |
struct _Fwd_list_impl |
| 620 |
: public _Node_alloc_type |
| 621 |
{ |
| 622 |
typename _Node_traits::_Node_base _M_head; |
| 623 |
|
| 624 |
_Fwd_list_impl() |
| 625 |
noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value) |
| 626 |
: _Node_alloc_type(), _M_head() |
| 627 |
{ } |
| 628 |
|
| 629 |
_Fwd_list_impl(_Fwd_list_impl&&) = default; |
| 630 |
|
| 631 |
_Fwd_list_impl(_Fwd_list_impl&& __fl, _Node_alloc_type&& __a) |
| 632 |
: _Node_alloc_type(std::move(__a)), _M_head(std::move(__fl._M_head)) |
| 633 |
{ } |
| 634 |
|
| 635 |
_Fwd_list_impl(_Node_alloc_type&& __a) |
| 636 |
: _Node_alloc_type(std::move(__a)), _M_head() |
| 637 |
{ } |
| 638 |
}; |
| 639 |
|
| 640 |
_Fwd_list_impl _M_impl; |
| 641 |
|
| 642 |
public: |
| 643 |
using iterator = typename _Node_traits::_Iterator; |
| 644 |
using const_iterator = typename _Node_traits::_Const_iterator; |
| 645 |
|
| 646 |
_Node_alloc_type& |
| 647 |
_M_get_Node_allocator() noexcept |
| 648 |
{ return this->_M_impl; } |
| 649 |
|
| 650 |
const _Node_alloc_type& |
| 651 |
_M_get_Node_allocator() const noexcept |
| 652 |
{ return this->_M_impl; } |
| 653 |
|
| 654 |
_Fwd_list_base() = default; |
| 655 |
|
| 656 |
_Fwd_list_base(_Node_alloc_type&& __a) |
| 657 |
: _M_impl(std::move(__a)) { } |
| 658 |
|
| 659 |
|
| 660 |
_Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a, |
| 661 |
std::true_type) |
| 662 |
: _M_impl(std::move(__lst._M_impl), std::move(__a)) |
| 663 |
{ } |
| 664 |
|
| 665 |
|
| 666 |
_Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a); |
| 667 |
|
| 668 |
_Fwd_list_base(_Fwd_list_base&&) = default; |
| 669 |
|
| 670 |
~_Fwd_list_base() |
| 671 |
{ _M_erase_after(_M_impl._M_head._M_base_ptr(), nullptr); } |
| 672 |
|
| 673 |
protected: |
| 674 |
#if ! _GLIBCXX_INLINE_VERSION |
| 675 |
|
| 676 |
_Node* |
| 677 |
_M_get_node() |
| 678 |
{ |
| 679 |
auto __ptr = _Node_alloc_traits::allocate(_M_get_Node_allocator(), 1); |
| 680 |
return std::__to_address(__ptr); |
| 681 |
} |
| 682 |
#endif |
| 683 |
|
| 684 |
void |
| 685 |
_M_put_node(_Node_ptr __p) |
| 686 |
{ |
| 687 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 688 |
_Node_alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); |
| 689 |
#else |
| 690 |
typedef typename _Node_alloc_traits::pointer _Ptr; |
| 691 |
auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__p); |
| 692 |
_Node_alloc_traits::deallocate(_M_get_Node_allocator(), __ptr, 1); |
| 693 |
#endif |
| 694 |
} |
| 695 |
|
| 696 |
template<typename... _Args> |
| 697 |
_Node_ptr |
| 698 |
_M_create_node(_Args&&... __args) |
| 699 |
{ |
| 700 |
auto& __alloc = _M_get_Node_allocator(); |
| 701 |
auto __guard = std::__allocate_guarded_obj(__alloc); |
| 702 |
_Node_alloc_traits::construct(__alloc, __guard->_M_valptr(), |
| 703 |
std::forward<_Args>(__args)...); |
| 704 |
auto __p = __guard.release(); |
| 705 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 706 |
return __p; |
| 707 |
#else |
| 708 |
return std::__to_address(__p); |
| 709 |
#endif |
| 710 |
} |
| 711 |
|
| 712 |
#pragma GCC diagnostic push |
| 713 |
#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr |
| 714 |
void |
| 715 |
_M_destroy_node(_Node_ptr __p) |
| 716 |
{ |
| 717 |
auto& __alloc = _M_get_Node_allocator(); |
| 718 |
|
| 719 |
_Node_alloc_traits::destroy(__alloc, __p->_M_valptr()); |
| 720 |
|
| 721 |
if constexpr (!is_trivially_destructible<_Base_ptr>::value) |
| 722 |
__p->~_Node(); |
| 723 |
_M_put_node(__p); |
| 724 |
} |
| 725 |
#pragma GCC diagnostic pop |
| 726 |
|
| 727 |
template<typename... _Args> |
| 728 |
_Base_ptr |
| 729 |
_M_insert_after(const_iterator __pos, _Args&&... __args); |
| 730 |
|
| 731 |
_Base_ptr |
| 732 |
_M_erase_after(_Base_ptr __pos); |
| 733 |
|
| 734 |
_Base_ptr |
| 735 |
_M_erase_after(_Base_ptr __pos, _Base_ptr __last); |
| 736 |
}; |
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
template<typename _Tp, typename _Alloc = allocator<_Tp>> |
| 767 |
class forward_list : private _Fwd_list_base<_Tp, _Alloc> |
| 768 |
{ |
| 769 |
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value, |
| 770 |
"std::forward_list must have a non-const, non-volatile value_type"); |
| 771 |
#if __cplusplus > 201703L || defined __STRICT_ANSI__ |
| 772 |
static_assert(is_same<typename _Alloc::value_type, _Tp>::value, |
| 773 |
"std::forward_list must have the same value_type as its allocator"); |
| 774 |
#endif |
| 775 |
|
| 776 |
private: |
| 777 |
typedef _Fwd_list_base<_Tp, _Alloc> _Base; |
| 778 |
typedef _Fwd_list_node_base _Node_base; |
| 779 |
typedef typename _Base::_Node _Node; |
| 780 |
typedef typename _Base::_Node_alloc_type _Node_alloc_type; |
| 781 |
typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; |
| 782 |
typedef allocator_traits<__alloc_rebind<_Alloc, _Tp>> _Alloc_traits; |
| 783 |
|
| 784 |
public: |
| 785 |
|
| 786 |
typedef _Tp value_type; |
| 787 |
typedef typename _Alloc_traits::pointer pointer; |
| 788 |
typedef typename _Alloc_traits::const_pointer const_pointer; |
| 789 |
typedef value_type& reference; |
| 790 |
typedef const value_type& const_reference; |
| 791 |
|
| 792 |
typedef typename _Base::iterator iterator; |
| 793 |
typedef typename _Base::const_iterator const_iterator; |
| 794 |
typedef std::size_t size_type; |
| 795 |
typedef std::ptrdiff_t difference_type; |
| 796 |
typedef _Alloc allocator_type; |
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
forward_list() = default; |
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
explicit |
| 810 |
forward_list(const _Alloc& __al) noexcept |
| 811 |
: _Base(_Node_alloc_type(__al)) |
| 812 |
{ } |
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
forward_list(const forward_list& __list, |
| 820 |
const __type_identity_t<_Alloc>& __al) |
| 821 |
: _Base(_Node_alloc_type(__al)) |
| 822 |
{ _M_range_initialize(__list.begin(), __list.end()); } |
| 823 |
|
| 824 |
private: |
| 825 |
forward_list(forward_list&& __list, _Node_alloc_type&& __al, |
| 826 |
false_type) |
| 827 |
: _Base(std::move(__list), std::move(__al)) |
| 828 |
{ |
| 829 |
|
| 830 |
|
| 831 |
insert_after(cbefore_begin(), |
| 832 |
std::__make_move_if_noexcept_iterator(__list.begin()), |
| 833 |
std::__make_move_if_noexcept_iterator(__list.end())); |
| 834 |
} |
| 835 |
|
| 836 |
forward_list(forward_list&& __list, _Node_alloc_type&& __al, |
| 837 |
true_type) |
| 838 |
noexcept |
| 839 |
: _Base(std::move(__list), _Node_alloc_type(__al), true_type{}) |
| 840 |
{ } |
| 841 |
|
| 842 |
public: |
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
forward_list(forward_list&& __list, |
| 849 |
const __type_identity_t<_Alloc>& __al) |
| 850 |
noexcept(_Node_alloc_traits::_S_always_equal()) |
| 851 |
: forward_list(std::move(__list), _Node_alloc_type(__al), |
| 852 |
typename _Node_alloc_traits::is_always_equal{}) |
| 853 |
{ } |
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
explicit |
| 864 |
forward_list(size_type __n, const _Alloc& __al = _Alloc()) |
| 865 |
: _Base(_Node_alloc_type(__al)) |
| 866 |
{ _M_default_initialize(__n); } |
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
forward_list(size_type __n, const _Tp& __value, |
| 878 |
const _Alloc& __al = _Alloc()) |
| 879 |
: _Base(_Node_alloc_type(__al)) |
| 880 |
{ _M_fill_initialize(__n, __value); } |
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
template<typename _InputIterator, |
| 893 |
typename = std::_RequireInputIter<_InputIterator>> |
| 894 |
forward_list(_InputIterator __first, _InputIterator __last, |
| 895 |
const _Alloc& __al = _Alloc()) |
| 896 |
: _Base(_Node_alloc_type(__al)) |
| 897 |
{ _M_range_initialize(__first, __last); } |
| 898 |
|
| 899 |
#if __glibcxx_containers_ranges |
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
template<__detail::__container_compatible_range<_Tp> _Rg> |
| 909 |
forward_list(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc()) |
| 910 |
: _Base(_Node_alloc_type(__a)) |
| 911 |
{ |
| 912 |
auto __to = this->_M_impl._M_head._M_base_ptr(); |
| 913 |
auto __first = ranges::begin(__rg); |
| 914 |
const auto __last = ranges::end(__rg); |
| 915 |
for (; __first != __last; ++__first) |
| 916 |
{ |
| 917 |
__to->_M_next = this->_M_create_node(*__first)->_M_base_ptr(); |
| 918 |
__to = __to->_M_next; |
| 919 |
} |
| 920 |
} |
| 921 |
#endif |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
forward_list(const forward_list& __list) |
| 929 |
: _Base(_Node_alloc_traits::_S_select_on_copy( |
| 930 |
__list._M_get_Node_allocator())) |
| 931 |
{ _M_range_initialize(__list.begin(), __list.end()); } |
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
forward_list(forward_list&&) = default; |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
forward_list(std::initializer_list<_Tp> __il, |
| 953 |
const _Alloc& __al = _Alloc()) |
| 954 |
: _Base(_Node_alloc_type(__al)) |
| 955 |
{ _M_range_initialize(__il.begin(), __il.end()); } |
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
~forward_list() noexcept |
| 961 |
{ } |
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
forward_list& |
| 973 |
operator=(const forward_list& __list); |
| 974 |
|
| 975 |
#pragma GCC diagnostic push |
| 976 |
#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
forward_list& |
| 990 |
operator=(forward_list&& __list) |
| 991 |
noexcept(_Node_alloc_traits::_S_nothrow_move()) |
| 992 |
{ |
| 993 |
constexpr bool __move_storage = |
| 994 |
_Node_alloc_traits::_S_propagate_on_move_assign() |
| 995 |
|| _Node_alloc_traits::_S_always_equal(); |
| 996 |
if constexpr (!__move_storage) |
| 997 |
{ |
| 998 |
if (__list._M_get_Node_allocator() != this->_M_get_Node_allocator()) |
| 999 |
{ |
| 1000 |
|
| 1001 |
|
| 1002 |
this->assign(std::make_move_iterator(__list.begin()), |
| 1003 |
std::make_move_iterator(__list.end())); |
| 1004 |
return *this; |
| 1005 |
} |
| 1006 |
} |
| 1007 |
|
| 1008 |
clear(); |
| 1009 |
this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next; |
| 1010 |
__list._M_impl._M_head._M_next = nullptr; |
| 1011 |
if constexpr (_Node_alloc_traits::_S_propagate_on_move_assign()) |
| 1012 |
this->_M_get_Node_allocator() |
| 1013 |
= std::move(__list._M_get_Node_allocator()); |
| 1014 |
return *this; |
| 1015 |
} |
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
forward_list& |
| 1026 |
operator=(std::initializer_list<_Tp> __il) |
| 1027 |
{ |
| 1028 |
assign(__il); |
| 1029 |
return *this; |
| 1030 |
} |
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
template<typename _InputIterator, |
| 1045 |
typename = std::_RequireInputIter<_InputIterator>> |
| 1046 |
void |
| 1047 |
assign(_InputIterator __first, _InputIterator __last) |
| 1048 |
{ |
| 1049 |
if constexpr (is_assignable<_Tp&, decltype(*__first)>::value) |
| 1050 |
{ |
| 1051 |
auto __prev = before_begin(); |
| 1052 |
auto __curr = begin(); |
| 1053 |
auto __end = end(); |
| 1054 |
while (__curr != __end && __first != __last) |
| 1055 |
{ |
| 1056 |
*__curr = *__first; |
| 1057 |
++__prev; |
| 1058 |
++__curr; |
| 1059 |
++__first; |
| 1060 |
} |
| 1061 |
if (__first != __last) |
| 1062 |
insert_after(__prev, __first, __last); |
| 1063 |
else if (__curr != __end) |
| 1064 |
erase_after(__prev, __end); |
| 1065 |
} |
| 1066 |
else |
| 1067 |
{ |
| 1068 |
clear(); |
| 1069 |
insert_after(cbefore_begin(), __first, __last); |
| 1070 |
} |
| 1071 |
} |
| 1072 |
#pragma GCC diagnostic pop |
| 1073 |
|
| 1074 |
#if __glibcxx_containers_ranges |
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
template<__detail::__container_compatible_range<_Tp> _Rg> |
| 1080 |
void |
| 1081 |
assign_range(_Rg&& __rg) |
| 1082 |
{ |
| 1083 |
static_assert(assignable_from<_Tp&, ranges::range_reference_t<_Rg>>); |
| 1084 |
|
| 1085 |
auto __first = ranges::begin(__rg); |
| 1086 |
const auto __last = ranges::end(__rg); |
| 1087 |
iterator __prev = before_begin(); |
| 1088 |
iterator __curr = begin(); |
| 1089 |
const iterator __end = end(); |
| 1090 |
|
| 1091 |
while (__curr != __end && __first != __last) |
| 1092 |
{ |
| 1093 |
*__curr = *__first; |
| 1094 |
__prev = __curr; |
| 1095 |
++__first; |
| 1096 |
++__curr; |
| 1097 |
} |
| 1098 |
|
| 1099 |
if (__curr != __end) |
| 1100 |
erase_after(__prev, __end); |
| 1101 |
else |
| 1102 |
insert_range_after(__prev, |
| 1103 |
ranges::subrange(std::move(__first), __last)); |
| 1104 |
} |
| 1105 |
#endif |
| 1106 |
|
| 1107 |
#pragma GCC diagnostic push |
| 1108 |
#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr |
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
void |
| 1120 |
assign(size_type __n, const _Tp& __val) |
| 1121 |
{ |
| 1122 |
if constexpr (is_copy_assignable<_Tp>::value) |
| 1123 |
{ |
| 1124 |
auto __prev = before_begin(); |
| 1125 |
auto __curr = begin(); |
| 1126 |
auto __end = end(); |
| 1127 |
while (__curr != __end && __n > 0) |
| 1128 |
{ |
| 1129 |
*__curr = __val; |
| 1130 |
++__prev; |
| 1131 |
++__curr; |
| 1132 |
--__n; |
| 1133 |
} |
| 1134 |
if (__n > 0) |
| 1135 |
insert_after(__prev, __n, __val); |
| 1136 |
else if (__curr != __end) |
| 1137 |
erase_after(__prev, __end); |
| 1138 |
} |
| 1139 |
else |
| 1140 |
{ |
| 1141 |
clear(); |
| 1142 |
insert_after(cbefore_begin(), __n, __val); |
| 1143 |
} |
| 1144 |
} |
| 1145 |
#pragma GCC diagnostic pop |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
void |
| 1156 |
assign(std::initializer_list<_Tp> __il) |
| 1157 |
{ assign(__il.begin(), __il.end()); } |
| 1158 |
|
| 1159 |
|
| 1160 |
allocator_type |
| 1161 |
get_allocator() const noexcept |
| 1162 |
{ return allocator_type(this->_M_get_Node_allocator()); } |
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
[[__nodiscard__]] |
| 1171 |
iterator |
| 1172 |
before_begin() noexcept |
| 1173 |
{ return iterator(this->_M_impl._M_head._M_base_ptr()); } |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
[[__nodiscard__]] |
| 1181 |
const_iterator |
| 1182 |
before_begin() const noexcept |
| 1183 |
{ return const_iterator(this->_M_impl._M_head._M_base_ptr()); } |
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
[[__nodiscard__]] |
| 1190 |
iterator |
| 1191 |
begin() noexcept |
| 1192 |
{ return iterator(this->_M_impl._M_head._M_next); } |
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
[[__nodiscard__]] |
| 1200 |
const_iterator |
| 1201 |
begin() const noexcept |
| 1202 |
{ return const_iterator(this->_M_impl._M_head._M_next); } |
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
[[__nodiscard__]] |
| 1210 |
iterator |
| 1211 |
end() noexcept |
| 1212 |
{ return iterator(nullptr); } |
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
[[__nodiscard__]] |
| 1220 |
const_iterator |
| 1221 |
end() const noexcept |
| 1222 |
{ return const_iterator(nullptr); } |
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
[[__nodiscard__]] |
| 1230 |
const_iterator |
| 1231 |
cbegin() const noexcept |
| 1232 |
{ return const_iterator(this->_M_impl._M_head._M_next); } |
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
[[__nodiscard__]] |
| 1240 |
const_iterator |
| 1241 |
cbefore_begin() const noexcept |
| 1242 |
{ return const_iterator(this->_M_impl._M_head._M_base_ptr()); } |
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
[[__nodiscard__]] |
| 1250 |
const_iterator |
| 1251 |
cend() const noexcept |
| 1252 |
{ return const_iterator(nullptr); } |
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
[[__nodiscard__]] |
| 1259 |
bool |
| 1260 |
empty() const noexcept |
| 1261 |
{ return this->_M_impl._M_head._M_next == nullptr; } |
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
[[__nodiscard__]] |
| 1267 |
size_type |
| 1268 |
max_size() const noexcept |
| 1269 |
{ return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); } |
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
[[__nodiscard__]] |
| 1278 |
reference |
| 1279 |
front() |
| 1280 |
{ |
| 1281 |
__glibcxx_requires_nonempty(); |
| 1282 |
_Node& __front = static_cast<_Node&>(*this->_M_impl._M_head._M_next); |
| 1283 |
return *__front._M_valptr(); |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
[[__nodiscard__]] |
| 1291 |
const_reference |
| 1292 |
front() const |
| 1293 |
{ |
| 1294 |
__glibcxx_requires_nonempty(); |
| 1295 |
_Node& __front = static_cast<_Node&>(*this->_M_impl._M_head._M_next); |
| 1296 |
return *__front._M_valptr(); |
| 1297 |
} |
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
template<typename... _Args> |
| 1313 |
#if __cplusplus > 201402L |
| 1314 |
reference |
| 1315 |
#else |
| 1316 |
void |
| 1317 |
#endif |
| 1318 |
emplace_front(_Args&&... __args) |
| 1319 |
{ |
| 1320 |
this->_M_insert_after(cbefore_begin(), |
| 1321 |
std::forward<_Args>(__args)...); |
| 1322 |
#if __cplusplus > 201402L |
| 1323 |
return front(); |
| 1324 |
#endif |
| 1325 |
} |
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
void |
| 1338 |
push_front(const _Tp& __val) |
| 1339 |
{ this->_M_insert_after(cbefore_begin(), __val); } |
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
void |
| 1345 |
push_front(_Tp&& __val) |
| 1346 |
{ this->_M_insert_after(cbefore_begin(), std::move(__val)); } |
| 1347 |
|
| 1348 |
#if __glibcxx_containers_ranges |
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
template<__detail::__container_compatible_range<_Tp> _Rg> |
| 1365 |
void |
| 1366 |
prepend_range(_Rg&& __rg) |
| 1367 |
{ |
| 1368 |
forward_list __tmp(from_range, std::forward<_Rg>(__rg), |
| 1369 |
get_allocator()); |
| 1370 |
if (!__tmp.empty()) |
| 1371 |
splice_after(before_begin(), __tmp); |
| 1372 |
} |
| 1373 |
#endif |
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
void |
| 1388 |
pop_front() |
| 1389 |
{ |
| 1390 |
__glibcxx_requires_nonempty(); |
| 1391 |
this->_M_erase_after(this->_M_impl._M_head._M_base_ptr()); |
| 1392 |
} |
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
template<typename... _Args> |
| 1408 |
iterator |
| 1409 |
emplace_after(const_iterator __pos, _Args&&... __args) |
| 1410 |
{ return iterator(this->_M_insert_after(__pos, |
| 1411 |
std::forward<_Args>(__args)...)); } |
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
iterator |
| 1426 |
insert_after(const_iterator __pos, const _Tp& __val) |
| 1427 |
{ return iterator(this->_M_insert_after(__pos, __val)); } |
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
iterator |
| 1433 |
insert_after(const_iterator __pos, _Tp&& __val) |
| 1434 |
{ return iterator(this->_M_insert_after(__pos, std::move(__val))); } |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
iterator |
| 1452 |
insert_after(const_iterator __pos, size_type __n, const _Tp& __val); |
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
template<typename _InputIterator, |
| 1470 |
typename = std::_RequireInputIter<_InputIterator>> |
| 1471 |
iterator |
| 1472 |
insert_after(const_iterator __pos, |
| 1473 |
_InputIterator __first, _InputIterator __last); |
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
iterator |
| 1491 |
insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) |
| 1492 |
{ return insert_after(__pos, __il.begin(), __il.end()); } |
| 1493 |
|
| 1494 |
#if __glibcxx_containers_ranges |
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
template<__detail::__container_compatible_range<_Tp> _Rg> |
| 1511 |
iterator |
| 1512 |
insert_range_after(const_iterator __position, _Rg&& __rg) |
| 1513 |
{ |
| 1514 |
forward_list __tmp(from_range, std::forward<_Rg>(__rg), |
| 1515 |
get_allocator()); |
| 1516 |
return _M_splice_after(__position, __tmp.before_begin(), __tmp.end()); |
| 1517 |
} |
| 1518 |
#endif |
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
iterator |
| 1538 |
erase_after(const_iterator __pos) |
| 1539 |
{ return iterator(this->_M_erase_after(__pos._M_const_cast()._M_node)); } |
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
iterator |
| 1561 |
erase_after(const_iterator __pos, const_iterator __last) |
| 1562 |
{ |
| 1563 |
return iterator(this->_M_erase_after(__pos._M_const_cast()._M_node, |
| 1564 |
__last._M_const_cast()._M_node)); |
| 1565 |
} |
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
void |
| 1580 |
swap(forward_list& __list) noexcept |
| 1581 |
{ |
| 1582 |
std::swap(this->_M_impl._M_head._M_next, |
| 1583 |
__list._M_impl._M_head._M_next); |
| 1584 |
_Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), |
| 1585 |
__list._M_get_Node_allocator()); |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
void |
| 1600 |
resize(size_type __sz); |
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
|
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
|
| 1613 |
|
| 1614 |
void |
| 1615 |
resize(size_type __sz, const value_type& __val); |
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
void |
| 1626 |
clear() noexcept |
| 1627 |
{ this->_M_erase_after(this->_M_impl._M_head._M_base_ptr(), nullptr); } |
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
void |
| 1643 |
splice_after(const_iterator __pos, forward_list&& __list) noexcept |
| 1644 |
{ |
| 1645 |
if (!__list.empty()) |
| 1646 |
_M_splice_after(__pos, __list.before_begin(), __list.end()); |
| 1647 |
} |
| 1648 |
|
| 1649 |
void |
| 1650 |
splice_after(const_iterator __pos, forward_list& __list) noexcept |
| 1651 |
{ splice_after(__pos, std::move(__list)); } |
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
void |
| 1664 |
splice_after(const_iterator __pos, forward_list&& __list, |
| 1665 |
const_iterator __i) noexcept; |
| 1666 |
|
| 1667 |
void |
| 1668 |
splice_after(const_iterator __pos, forward_list& __list, |
| 1669 |
const_iterator __i) noexcept |
| 1670 |
{ splice_after(__pos, std::move(__list), __i); } |
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
void |
| 1687 |
splice_after(const_iterator __pos, forward_list&&, |
| 1688 |
const_iterator __before, const_iterator __last) noexcept |
| 1689 |
{ _M_splice_after(__pos, __before, __last); } |
| 1690 |
|
| 1691 |
void |
| 1692 |
splice_after(const_iterator __pos, forward_list&, |
| 1693 |
const_iterator __before, const_iterator __last) noexcept |
| 1694 |
{ _M_splice_after(__pos, __before, __last); } |
| 1695 |
|
| 1696 |
|
| 1697 |
private: |
| 1698 |
#ifdef __glibcxx_list_remove_return_type |
| 1699 |
using __remove_return_type = size_type; |
| 1700 |
# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \ |
| 1701 |
__attribute__((__abi_tag__("__cxx20"))) |
| 1702 |
#else |
| 1703 |
using __remove_return_type = void; |
| 1704 |
# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG |
| 1705 |
#endif |
| 1706 |
public: |
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
_GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG |
| 1720 |
__remove_return_type |
| 1721 |
remove(const _Tp& __val); |
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
template<typename _Pred> |
| 1735 |
__remove_return_type |
| 1736 |
remove_if(_Pred __pred); |
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
_GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG |
| 1749 |
__remove_return_type |
| 1750 |
unique() |
| 1751 |
{ return unique(std::equal_to<_Tp>()); } |
| 1752 |
|
| 1753 |
#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG |
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
template<typename _BinPred> |
| 1768 |
__remove_return_type |
| 1769 |
unique(_BinPred __binary_pred); |
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
void |
| 1781 |
merge(forward_list&& __list) |
| 1782 |
{ merge(std::move(__list), std::less<_Tp>()); } |
| 1783 |
|
| 1784 |
void |
| 1785 |
merge(forward_list& __list) |
| 1786 |
{ merge(std::move(__list)); } |
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
template<typename _Comp> |
| 1800 |
void |
| 1801 |
merge(forward_list&& __list, _Comp __comp); |
| 1802 |
|
| 1803 |
template<typename _Comp> |
| 1804 |
void |
| 1805 |
merge(forward_list& __list, _Comp __comp) |
| 1806 |
{ merge(std::move(__list), __comp); } |
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
void |
| 1815 |
sort() |
| 1816 |
{ sort(std::less<_Tp>()); } |
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
template<typename _Comp> |
| 1825 |
void |
| 1826 |
sort(_Comp __comp); |
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
void |
| 1834 |
reverse() noexcept |
| 1835 |
{ this->_M_impl._M_head._M_reverse_after(); } |
| 1836 |
|
| 1837 |
private: |
| 1838 |
|
| 1839 |
template<typename _InputIterator> |
| 1840 |
void |
| 1841 |
_M_range_initialize(_InputIterator __first, _InputIterator __last); |
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
void |
| 1846 |
_M_fill_initialize(size_type __n, const value_type& __value); |
| 1847 |
|
| 1848 |
|
| 1849 |
iterator |
| 1850 |
_M_splice_after(const_iterator __pos, const_iterator __before, |
| 1851 |
const_iterator __last); |
| 1852 |
|
| 1853 |
|
| 1854 |
void |
| 1855 |
_M_default_initialize(size_type __n); |
| 1856 |
|
| 1857 |
|
| 1858 |
void |
| 1859 |
_M_default_insert_after(const_iterator __pos, size_type __n); |
| 1860 |
|
| 1861 |
#if ! _GLIBCXX_INLINE_VERSION |
| 1862 |
#pragma GCC diagnostic push |
| 1863 |
#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr |
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
void |
| 1877 |
_M_move_assign(forward_list&& __list, true_type) noexcept |
| 1878 |
{ |
| 1879 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 1880 |
if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value) |
| 1881 |
#endif |
| 1882 |
{ |
| 1883 |
clear(); |
| 1884 |
this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next; |
| 1885 |
__list._M_impl._M_head._M_next = nullptr; |
| 1886 |
std::__alloc_on_move(this->_M_get_Node_allocator(), |
| 1887 |
__list._M_get_Node_allocator()); |
| 1888 |
} |
| 1889 |
} |
| 1890 |
|
| 1891 |
void |
| 1892 |
_M_move_assign(forward_list&& __list, false_type) |
| 1893 |
{ |
| 1894 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 1895 |
if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value) |
| 1896 |
#endif |
| 1897 |
{ |
| 1898 |
if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator()) |
| 1899 |
_M_move_assign(std::move(__list), true_type()); |
| 1900 |
else |
| 1901 |
|
| 1902 |
|
| 1903 |
this->assign(std::make_move_iterator(__list.begin()), |
| 1904 |
std::make_move_iterator(__list.end())); |
| 1905 |
} |
| 1906 |
} |
| 1907 |
|
| 1908 |
void |
| 1909 |
_M_assign_n(size_type __n, const _Tp& __val, true_type) |
| 1910 |
{ |
| 1911 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 1912 |
if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value) |
| 1913 |
#endif |
| 1914 |
{ |
| 1915 |
auto __prev = before_begin(); |
| 1916 |
auto __curr = begin(); |
| 1917 |
auto __end = end(); |
| 1918 |
while (__curr != __end && __n > 0) |
| 1919 |
{ |
| 1920 |
*__curr = __val; |
| 1921 |
++__prev; |
| 1922 |
++__curr; |
| 1923 |
--__n; |
| 1924 |
} |
| 1925 |
if (__n > 0) |
| 1926 |
insert_after(__prev, __n, __val); |
| 1927 |
else if (__curr != __end) |
| 1928 |
erase_after(__prev, __end); |
| 1929 |
} |
| 1930 |
} |
| 1931 |
|
| 1932 |
void |
| 1933 |
_M_assign_n(size_type __n, const _Tp& __val, false_type) |
| 1934 |
{ |
| 1935 |
#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST |
| 1936 |
if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value) |
| 1937 |
#endif |
| 1938 |
{ |
| 1939 |
clear(); |
| 1940 |
insert_after(cbefore_begin(), __n, __val); |
| 1941 |
} |
| 1942 |
} |
| 1943 |
#pragma GCC diagnostic pop |
| 1944 |
#endif |
| 1945 |
}; |
| 1946 |
|
| 1947 |
#if __cpp_deduction_guides >= 201606 |
| 1948 |
template<typename _InputIterator, typename _ValT |
| 1949 |
= typename iterator_traits<_InputIterator>::value_type, |
| 1950 |
typename _Allocator = allocator<_ValT>, |
| 1951 |
typename = _RequireInputIter<_InputIterator>, |
| 1952 |
typename = _RequireAllocator<_Allocator>> |
| 1953 |
forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 1954 |
-> forward_list<_ValT, _Allocator>; |
| 1955 |
|
| 1956 |
#if __glibcxx_containers_ranges |
| 1957 |
template<ranges::input_range _Rg, |
| 1958 |
typename _Allocator = allocator<ranges::range_value_t<_Rg>>> |
| 1959 |
forward_list(from_range_t, _Rg&&, _Allocator = _Allocator()) |
| 1960 |
-> forward_list<ranges::range_value_t<_Rg>, _Allocator>; |
| 1961 |
#endif |
| 1962 |
#endif |
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
template<typename _Tp, typename _Alloc> |
| 1975 |
[[__nodiscard__]] |
| 1976 |
bool |
| 1977 |
operator==(const forward_list<_Tp, _Alloc>& __lx, |
| 1978 |
const forward_list<_Tp, _Alloc>& __ly); |
| 1979 |
|
| 1980 |
#if __cpp_lib_three_way_comparison |
| 1981 |
|
| 1982 |
|
| 1983 |
|
| 1984 |
|
| 1985 |
|
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
|
| 1992 |
template<typename _Tp, typename _Alloc> |
| 1993 |
[[nodiscard]] |
| 1994 |
inline __detail::__synth3way_t<_Tp> |
| 1995 |
operator<=>(const forward_list<_Tp, _Alloc>& __x, |
| 1996 |
const forward_list<_Tp, _Alloc>& __y) |
| 1997 |
{ |
| 1998 |
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), |
| 1999 |
__y.begin(), __y.end(), |
| 2000 |
__detail::__synth3way); |
| 2001 |
} |
| 2002 |
#else |
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
|
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
|
| 2015 |
template<typename _Tp, typename _Alloc> |
| 2016 |
[[__nodiscard__]] |
| 2017 |
inline bool |
| 2018 |
operator<(const forward_list<_Tp, _Alloc>& __lx, |
| 2019 |
const forward_list<_Tp, _Alloc>& __ly) |
| 2020 |
{ return std::lexicographical_compare(__lx.cbegin(), __lx.cend(), |
| 2021 |
__ly.cbegin(), __ly.cend()); } |
| 2022 |
|
| 2023 |
|
| 2024 |
template<typename _Tp, typename _Alloc> |
| 2025 |
[[__nodiscard__]] |
| 2026 |
inline bool |
| 2027 |
operator!=(const forward_list<_Tp, _Alloc>& __lx, |
| 2028 |
const forward_list<_Tp, _Alloc>& __ly) |
| 2029 |
{ return !(__lx == __ly); } |
| 2030 |
|
| 2031 |
|
| 2032 |
template<typename _Tp, typename _Alloc> |
| 2033 |
[[__nodiscard__]] |
| 2034 |
inline bool |
| 2035 |
operator>(const forward_list<_Tp, _Alloc>& __lx, |
| 2036 |
const forward_list<_Tp, _Alloc>& __ly) |
| 2037 |
{ return (__ly < __lx); } |
| 2038 |
|
| 2039 |
|
| 2040 |
template<typename _Tp, typename _Alloc> |
| 2041 |
[[__nodiscard__]] |
| 2042 |
inline bool |
| 2043 |
operator>=(const forward_list<_Tp, _Alloc>& __lx, |
| 2044 |
const forward_list<_Tp, _Alloc>& __ly) |
| 2045 |
{ return !(__lx < __ly); } |
| 2046 |
|
| 2047 |
|
| 2048 |
template<typename _Tp, typename _Alloc> |
| 2049 |
[[__nodiscard__]] |
| 2050 |
inline bool |
| 2051 |
operator<=(const forward_list<_Tp, _Alloc>& __lx, |
| 2052 |
const forward_list<_Tp, _Alloc>& __ly) |
| 2053 |
{ return !(__ly < __lx); } |
| 2054 |
#endif |
| 2055 |
|
| 2056 |
|
| 2057 |
template<typename _Tp, typename _Alloc> |
| 2058 |
inline void |
| 2059 |
swap(forward_list<_Tp, _Alloc>& __lx, |
| 2060 |
forward_list<_Tp, _Alloc>& __ly) |
| 2061 |
noexcept(noexcept(__lx.swap(__ly))) |
| 2062 |
{ __lx.swap(__ly); } |
| 2063 |
|
| 2064 |
_GLIBCXX_END_NAMESPACE_CONTAINER |
| 2065 |
_GLIBCXX_END_NAMESPACE_VERSION |
| 2066 |
} |
| 2067 |
|
| 2068 |
#endif |