]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/debug/deque
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / debug / deque
CommitLineData
285b36d6
BK
1// Debugging deque implementation -*- C++ -*-
2
99dee823 3// Copyright (C) 2003-2021 Free Software Foundation, Inc.
285b36d6
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
285b36d6
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
285b36d6 24
78a53887
BK
25/** @file debug/deque
26 * This file is a GNU debug extension to the Standard C++ Library.
27 */
28
285b36d6
BK
29#ifndef _GLIBCXX_DEBUG_DEQUE
30#define _GLIBCXX_DEBUG_DEQUE 1
31
541a9b10
JW
32#pragma GCC system_header
33
9ca2ac69
JW
34#include <bits/c++config.h>
35namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
36 template<typename _Tp, typename _Allocator> class deque;
37} } // namespace std::__debug
38
285b36d6
BK
39#include <deque>
40#include <debug/safe_sequence.h>
15ee1a77 41#include <debug/safe_container.h>
285b36d6
BK
42#include <debug/safe_iterator.h>
43
12ffa228 44namespace std _GLIBCXX_VISIBILITY(default)
3cbc7af0 45{
45f388bb 46namespace __debug
285b36d6 47{
1ceb9e06 48 /// Class std::deque with safety/checking/debug instrumentation.
285b36d6 49 template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
526da49c 50 class deque
15ee1a77
FD
51 : public __gnu_debug::_Safe_container<
52 deque<_Tp, _Allocator>, _Allocator,
b6f86694 53 __gnu_debug::_Safe_sequence>,
15ee1a77 54 public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
285b36d6 55 {
15ee1a77
FD
56 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
57 typedef __gnu_debug::_Safe_container<
b6f86694 58 deque, _Allocator, __gnu_debug::_Safe_sequence> _Safe;
285b36d6 59
15ee1a77
FD
60 typedef typename _Base::const_iterator _Base_const_iterator;
61 typedef typename _Base::iterator _Base_iterator;
afe96d41 62 typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
15ee1a77 63
e9afbed0
FD
64 template<typename _ItT, typename _SeqT, typename _CatT>
65 friend class ::__gnu_debug::_Safe_iterator;
66
eca833b8
JW
67 // Reference wrapper for base class. Disambiguates deque(const _Base&)
68 // from copy constructor by requiring a user-defined conversion.
69 // See PR libstdc++/90102.
70 struct _Base_ref
71 {
72 _Base_ref(const _Base& __r) : _M_ref(__r) { }
73
74 const _Base& _M_ref;
75 };
76
285b36d6 77 public:
15ee1a77
FD
78 typedef typename _Base::reference reference;
79 typedef typename _Base::const_reference const_reference;
526da49c 80
15ee1a77
FD
81 typedef __gnu_debug::_Safe_iterator<_Base_iterator, deque>
82 iterator;
83 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, deque>
84 const_iterator;
526da49c 85
15ee1a77
FD
86 typedef typename _Base::size_type size_type;
87 typedef typename _Base::difference_type difference_type;
526da49c 88
15ee1a77
FD
89 typedef _Tp value_type;
90 typedef _Allocator allocator_type;
91 typedef typename _Base::pointer pointer;
92 typedef typename _Base::const_pointer const_pointer;
93 typedef std::reverse_iterator<iterator> reverse_iterator;
94 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
285b36d6
BK
95
96 // 23.2.1.1 construct/copy/destroy:
c3cdd71f 97
15ee1a77
FD
98#if __cplusplus < 201103L
99 deque()
100 : _Base() { }
101
102 deque(const deque& __x)
103 : _Base(__x) { }
104
105 ~deque() { }
106#else
107 deque() = default;
108 deque(const deque&) = default;
109 deque(deque&&) = default;
110
fd18c76a
JW
111 deque(const deque& __d, const _Allocator& __a)
112 : _Base(__d, __a) { }
113
114 deque(deque&& __d, const _Allocator& __a)
115 : _Safe(std::move(__d)), _Base(std::move(__d), __a) { }
116
15ee1a77
FD
117 deque(initializer_list<value_type> __l,
118 const allocator_type& __a = allocator_type())
119 : _Base(__l, __a) { }
120
121 ~deque() = default;
122#endif
c3cdd71f 123
dc2cf706 124 explicit
c3cdd71f 125 deque(const _Allocator& __a)
285b36d6
BK
126 : _Base(__a) { }
127
734f5023 128#if __cplusplus >= 201103L
dc2cf706 129 explicit
fd18c76a
JW
130 deque(size_type __n, const _Allocator& __a = _Allocator())
131 : _Base(__n, __a) { }
dc2cf706
PC
132
133 deque(size_type __n, const _Tp& __value,
134 const _Allocator& __a = _Allocator())
135 : _Base(__n, __value, __a) { }
136#else
137 explicit
138 deque(size_type __n, const _Tp& __value = _Tp(),
139 const _Allocator& __a = _Allocator())
285b36d6 140 : _Base(__n, __value, __a) { }
dc2cf706 141#endif
285b36d6 142
734f5023 143#if __cplusplus >= 201103L
2203cb90
PC
144 template<class _InputIterator,
145 typename = std::_RequireInputIter<_InputIterator>>
146#else
285b36d6 147 template<class _InputIterator>
2203cb90 148#endif
15ee1a77 149 deque(_InputIterator __first, _InputIterator __last,
285b36d6 150 const _Allocator& __a = _Allocator())
90aabc7e
FD
151 : _Base(__gnu_debug::__base(
152 __glibcxx_check_valid_constructor_range(__first, __last)),
1f5ca1a1 153 __gnu_debug::__base(__last), __a)
15ee1a77 154 { }
285b36d6 155
eca833b8
JW
156 deque(_Base_ref __x)
157 : _Base(__x._M_ref) { }
ed540c0a 158
15ee1a77 159#if __cplusplus < 201103L
ed540c0a
CJ
160 deque&
161 operator=(const deque& __x)
285b36d6 162 {
15ee1a77
FD
163 this->_M_safe() = __x;
164 _M_base() = __x;
285b36d6
BK
165 return *this;
166 }
15ee1a77
FD
167#else
168 deque&
169 operator=(const deque&) = default;
526da49c 170
ed540c0a 171 deque&
15ee1a77 172 operator=(deque&&) = default;
988499f4
JM
173
174 deque&
175 operator=(initializer_list<value_type> __l)
176 {
15ee1a77 177 _M_base() = __l;
988499f4
JM
178 this->_M_invalidate_all();
179 return *this;
180 }
ed540c0a
CJ
181#endif
182
734f5023 183#if __cplusplus >= 201103L
2203cb90
PC
184 template<class _InputIterator,
185 typename = std::_RequireInputIter<_InputIterator>>
186#else
285b36d6 187 template<class _InputIterator>
2203cb90 188#endif
15ee1a77
FD
189 void
190 assign(_InputIterator __first, _InputIterator __last)
191 {
24167c42
FD
192 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
193 __glibcxx_check_valid_range2(__first, __last, __dist);
194 if (__dist.second >= __gnu_debug::__dp_sign)
195 _Base::assign(__gnu_debug::__unsafe(__first),
196 __gnu_debug::__unsafe(__last));
197 else
198 _Base::assign(__first, __last);
199
285b36d6
BK
200 this->_M_invalidate_all();
201 }
202
526da49c 203 void
285b36d6
BK
204 assign(size_type __n, const _Tp& __t)
205 {
206 _Base::assign(__n, __t);
207 this->_M_invalidate_all();
208 }
526da49c 209
734f5023 210#if __cplusplus >= 201103L
988499f4
JM
211 void
212 assign(initializer_list<value_type> __l)
213 {
214 _Base::assign(__l);
215 this->_M_invalidate_all();
216 }
217#endif
218
285b36d6 219 using _Base::get_allocator;
526da49c 220
285b36d6 221 // iterators:
526da49c 222 iterator
d3677132 223 begin() _GLIBCXX_NOEXCEPT
285b36d6 224 { return iterator(_Base::begin(), this); }
526da49c
BI
225
226 const_iterator
d3677132 227 begin() const _GLIBCXX_NOEXCEPT
285b36d6 228 { return const_iterator(_Base::begin(), this); }
526da49c
BI
229
230 iterator
d3677132 231 end() _GLIBCXX_NOEXCEPT
285b36d6 232 { return iterator(_Base::end(), this); }
526da49c
BI
233
234 const_iterator
d3677132 235 end() const _GLIBCXX_NOEXCEPT
285b36d6 236 { return const_iterator(_Base::end(), this); }
526da49c
BI
237
238 reverse_iterator
d3677132 239 rbegin() _GLIBCXX_NOEXCEPT
285b36d6 240 { return reverse_iterator(end()); }
526da49c
BI
241
242 const_reverse_iterator
d3677132 243 rbegin() const _GLIBCXX_NOEXCEPT
285b36d6 244 { return const_reverse_iterator(end()); }
526da49c
BI
245
246 reverse_iterator
d3677132 247 rend() _GLIBCXX_NOEXCEPT
285b36d6 248 { return reverse_iterator(begin()); }
526da49c
BI
249
250 const_reverse_iterator
d3677132 251 rend() const _GLIBCXX_NOEXCEPT
285b36d6 252 { return const_reverse_iterator(begin()); }
526da49c 253
734f5023 254#if __cplusplus >= 201103L
0cd50f89 255 const_iterator
d3677132 256 cbegin() const noexcept
0cd50f89
PC
257 { return const_iterator(_Base::begin(), this); }
258
259 const_iterator
d3677132 260 cend() const noexcept
0cd50f89
PC
261 { return const_iterator(_Base::end(), this); }
262
263 const_reverse_iterator
d3677132 264 crbegin() const noexcept
0cd50f89
PC
265 { return const_reverse_iterator(end()); }
266
267 const_reverse_iterator
d3677132 268 crend() const noexcept
0cd50f89
PC
269 { return const_reverse_iterator(begin()); }
270#endif
271
afe96d41
FD
272 private:
273 void
274 _M_invalidate_after_nth(difference_type __n)
275 {
276 typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
277 this->_M_invalidate_if(_After_nth(__n, _Base::begin()));
278 }
15ee1a77 279
afe96d41 280 public:
285b36d6
BK
281 // 23.2.1.2 capacity:
282 using _Base::size;
283 using _Base::max_size;
526da49c 284
734f5023 285#if __cplusplus >= 201103L
dc2cf706
PC
286 void
287 resize(size_type __sz)
288 {
dc2cf706
PC
289 bool __invalidate_all = __sz > this->size();
290 if (__sz < this->size())
afe96d41 291 this->_M_invalidate_after_nth(__sz);
dc2cf706
PC
292
293 _Base::resize(__sz);
294
295 if (__invalidate_all)
296 this->_M_invalidate_all();
297 }
298
299 void
300 resize(size_type __sz, const _Tp& __c)
301 {
dc2cf706
PC
302 bool __invalidate_all = __sz > this->size();
303 if (__sz < this->size())
afe96d41 304 this->_M_invalidate_after_nth(__sz);
dc2cf706
PC
305
306 _Base::resize(__sz, __c);
307
308 if (__invalidate_all)
309 this->_M_invalidate_all();
310 }
311#else
526da49c 312 void
285b36d6
BK
313 resize(size_type __sz, _Tp __c = _Tp())
314 {
285b36d6
BK
315 bool __invalidate_all = __sz > this->size();
316 if (__sz < this->size())
afe96d41 317 this->_M_invalidate_after_nth(__sz);
526da49c 318
285b36d6 319 _Base::resize(__sz, __c);
526da49c 320
285b36d6
BK
321 if (__invalidate_all)
322 this->_M_invalidate_all();
323 }
dc2cf706 324#endif
526da49c 325
734f5023 326#if __cplusplus >= 201103L
8a752dfe 327 void
d15ac9d9 328 shrink_to_fit() noexcept
8a752dfe
FD
329 {
330 if (_Base::_M_shrink_to_fit())
331 this->_M_invalidate_all();
332 }
79667f82
PC
333#endif
334
285b36d6 335 using _Base::empty;
526da49c 336
285b36d6 337 // element access:
526da49c 338 reference
d15ac9d9 339 operator[](size_type __n) _GLIBCXX_NOEXCEPT
285b36d6
BK
340 {
341 __glibcxx_check_subscript(__n);
342 return _M_base()[__n];
343 }
526da49c
BI
344
345 const_reference
d15ac9d9 346 operator[](size_type __n) const _GLIBCXX_NOEXCEPT
285b36d6
BK
347 {
348 __glibcxx_check_subscript(__n);
349 return _M_base()[__n];
350 }
526da49c 351
285b36d6 352 using _Base::at;
526da49c
BI
353
354 reference
d15ac9d9 355 front() _GLIBCXX_NOEXCEPT
285b36d6
BK
356 {
357 __glibcxx_check_nonempty();
358 return _Base::front();
359 }
526da49c
BI
360
361 const_reference
d15ac9d9 362 front() const _GLIBCXX_NOEXCEPT
285b36d6
BK
363 {
364 __glibcxx_check_nonempty();
365 return _Base::front();
366 }
526da49c
BI
367
368 reference
d15ac9d9 369 back() _GLIBCXX_NOEXCEPT
285b36d6
BK
370 {
371 __glibcxx_check_nonempty();
372 return _Base::back();
373 }
526da49c
BI
374
375 const_reference
d15ac9d9 376 back() const _GLIBCXX_NOEXCEPT
285b36d6
BK
377 {
378 __glibcxx_check_nonempty();
379 return _Base::back();
380 }
526da49c 381
285b36d6 382 // 23.2.1.3 modifiers:
526da49c 383 void
285b36d6
BK
384 push_front(const _Tp& __x)
385 {
386 _Base::push_front(__x);
387 this->_M_invalidate_all();
388 }
526da49c
BI
389
390 void
285b36d6
BK
391 push_back(const _Tp& __x)
392 {
393 _Base::push_back(__x);
394 this->_M_invalidate_all();
395 }
4dc3e453 396
734f5023 397#if __cplusplus >= 201103L
4dc3e453
PC
398 void
399 push_front(_Tp&& __x)
400 { emplace_front(std::move(__x)); }
401
402 void
403 push_back(_Tp&& __x)
404 { emplace_back(std::move(__x)); }
405
7ffec97f 406 template<typename... _Args>
594ef205
JW
407#if __cplusplus > 201402L
408 reference
409#else
15ee1a77 410 void
594ef205 411#endif
15ee1a77 412 emplace_front(_Args&&... __args)
7ffec97f 413 {
4dc3e453 414 _Base::emplace_front(std::forward<_Args>(__args)...);
7ffec97f 415 this->_M_invalidate_all();
594ef205
JW
416#if __cplusplus > 201402L
417 return front();
418#endif
7ffec97f
CJ
419 }
420
421 template<typename... _Args>
594ef205
JW
422#if __cplusplus > 201402L
423 reference
424#else
15ee1a77 425 void
594ef205 426#endif
15ee1a77 427 emplace_back(_Args&&... __args)
7ffec97f 428 {
4dc3e453 429 _Base::emplace_back(std::forward<_Args>(__args)...);
7ffec97f 430 this->_M_invalidate_all();
594ef205
JW
431#if __cplusplus > 201402L
432 return back();
433#endif
7ffec97f
CJ
434 }
435
436 template<typename... _Args>
15ee1a77
FD
437 iterator
438 emplace(const_iterator __position, _Args&&... __args)
7ffec97f
CJ
439 {
440 __glibcxx_check_insert(__position);
afe96d41
FD
441 _Base_iterator __res = _Base::emplace(__position.base(),
442 std::forward<_Args>(__args)...);
7ffec97f
CJ
443 this->_M_invalidate_all();
444 return iterator(__res, this);
445 }
446#endif
526da49c
BI
447
448 iterator
7b61c5a9
PC
449#if __cplusplus >= 201103L
450 insert(const_iterator __position, const _Tp& __x)
451#else
285b36d6 452 insert(iterator __position, const _Tp& __x)
7b61c5a9 453#endif
285b36d6
BK
454 {
455 __glibcxx_check_insert(__position);
afe96d41 456 _Base_iterator __res = _Base::insert(__position.base(), __x);
285b36d6
BK
457 this->_M_invalidate_all();
458 return iterator(__res, this);
459 }
526da49c 460
734f5023 461#if __cplusplus >= 201103L
7ffec97f 462 iterator
7b61c5a9 463 insert(const_iterator __position, _Tp&& __x)
360b7bff 464 { return emplace(__position, std::move(__x)); }
988499f4 465
06eed9f5
PC
466 iterator
467 insert(const_iterator __position, initializer_list<value_type> __l)
988499f4 468 {
06eed9f5
PC
469 __glibcxx_check_insert(__position);
470 _Base_iterator __res = _Base::insert(__position.base(), __l);
988499f4 471 this->_M_invalidate_all();
06eed9f5 472 return iterator(__res, this);
988499f4 473 }
7ffec97f
CJ
474#endif
475
06eed9f5
PC
476#if __cplusplus >= 201103L
477 iterator
478 insert(const_iterator __position, size_type __n, const _Tp& __x)
479 {
480 __glibcxx_check_insert(__position);
481 _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
482 this->_M_invalidate_all();
483 return iterator(__res, this);
484 }
485#else
526da49c 486 void
285b36d6
BK
487 insert(iterator __position, size_type __n, const _Tp& __x)
488 {
489 __glibcxx_check_insert(__position);
490 _Base::insert(__position.base(), __n, __x);
491 this->_M_invalidate_all();
492 }
06eed9f5 493#endif
526da49c 494
734f5023 495#if __cplusplus >= 201103L
2203cb90
PC
496 template<class _InputIterator,
497 typename = std::_RequireInputIter<_InputIterator>>
06eed9f5 498 iterator
15ee1a77 499 insert(const_iterator __position,
06eed9f5 500 _InputIterator __first, _InputIterator __last)
15ee1a77 501 {
24167c42
FD
502 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
503 __glibcxx_check_insert_range(__position, __first, __last, __dist);
504 _Base_iterator __res;
505 if (__dist.second >= __gnu_debug::__dp_sign)
506 __res = _Base::insert(__position.base(),
507 __gnu_debug::__unsafe(__first),
508 __gnu_debug::__unsafe(__last));
509 else
510 __res = _Base::insert(__position.base(), __first, __last);
511
06eed9f5
PC
512 this->_M_invalidate_all();
513 return iterator(__res, this);
514 }
2203cb90 515#else
285b36d6 516 template<class _InputIterator>
15ee1a77
FD
517 void
518 insert(iterator __position,
285b36d6 519 _InputIterator __first, _InputIterator __last)
15ee1a77 520 {
24167c42
FD
521 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
522 __glibcxx_check_insert_range(__position, __first, __last, __dist);
523
524 if (__dist.second >= __gnu_debug::__dp_sign)
525 _Base::insert(__position.base(),
526 __gnu_debug::__unsafe(__first),
527 __gnu_debug::__unsafe(__last));
528 else
529 _Base::insert(__position.base(), __first, __last);
530
285b36d6
BK
531 this->_M_invalidate_all();
532 }
06eed9f5 533#endif
526da49c
BI
534
535 void
d15ac9d9 536 pop_front() _GLIBCXX_NOEXCEPT
285b36d6
BK
537 {
538 __glibcxx_check_nonempty();
afe96d41 539 this->_M_invalidate_if(_Equal(_Base::begin()));
285b36d6
BK
540 _Base::pop_front();
541 }
526da49c
BI
542
543 void
d15ac9d9 544 pop_back() _GLIBCXX_NOEXCEPT
285b36d6
BK
545 {
546 __glibcxx_check_nonempty();
afe96d41 547 this->_M_invalidate_if(_Equal(--_Base::end()));
285b36d6
BK
548 _Base::pop_back();
549 }
526da49c
BI
550
551 iterator
94938aec
PC
552#if __cplusplus >= 201103L
553 erase(const_iterator __position)
554#else
555 erase(iterator __position)
556#endif
285b36d6
BK
557 {
558 __glibcxx_check_erase(__position);
94938aec
PC
559#if __cplusplus >= 201103L
560 _Base_const_iterator __victim = __position.base();
561#else
afe96d41 562 _Base_iterator __victim = __position.base();
94938aec
PC
563#endif
564 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
285b36d6 565 {
afe96d41
FD
566 this->_M_invalidate_if(_Equal(__victim));
567 return iterator(_Base::erase(__victim), this);
285b36d6
BK
568 }
569 else
570 {
afe96d41 571 _Base_iterator __res = _Base::erase(__victim);
285b36d6
BK
572 this->_M_invalidate_all();
573 return iterator(__res, this);
574 }
575 }
526da49c
BI
576
577 iterator
94938aec
PC
578#if __cplusplus >= 201103L
579 erase(const_iterator __first, const_iterator __last)
580#else
285b36d6 581 erase(iterator __first, iterator __last)
94938aec 582#endif
285b36d6
BK
583 {
584 // _GLIBCXX_RESOLVE_LIB_DEFECTS
585 // 151. can't currently clear() empty container
586 __glibcxx_check_erase_range(__first, __last);
a7cee01d 587
cdfa3dbb 588 if (__first.base() == __last.base())
94938aec
PC
589#if __cplusplus >= 201103L
590 return iterator(__first.base()._M_const_cast(), this);
591#else
a7cee01d 592 return __first;
94938aec 593#endif
15ee1a77 594 else if (__first.base() == _Base::begin()
a7cee01d 595 || __last.base() == _Base::end())
285b36d6
BK
596 {
597 this->_M_detach_singular();
94938aec 598 for (_Base_const_iterator __position = __first.base();
afe96d41 599 __position != __last.base(); ++__position)
285b36d6 600 {
afe96d41 601 this->_M_invalidate_if(_Equal(__position));
285b36d6 602 }
bc2631e0 603 __try
526da49c 604 {
285b36d6 605 return iterator(_Base::erase(__first.base(), __last.base()),
526da49c 606 this);
285b36d6 607 }
bc2631e0 608 __catch(...)
285b36d6
BK
609 {
610 this->_M_revalidate_singular();
611 __throw_exception_again;
612 }
613 }
614 else
615 {
afe96d41
FD
616 _Base_iterator __res = _Base::erase(__first.base(),
617 __last.base());
285b36d6
BK
618 this->_M_invalidate_all();
619 return iterator(__res, this);
620 }
621 }
526da49c
BI
622
623 void
15ee1a77 624 swap(deque& __x)
c5d9ec56 625 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
285b36d6 626 {
15ee1a77 627 _Safe::_M_swap(__x);
285b36d6 628 _Base::swap(__x);
285b36d6 629 }
526da49c
BI
630
631 void
d3677132 632 clear() _GLIBCXX_NOEXCEPT
285b36d6
BK
633 {
634 _Base::clear();
635 this->_M_invalidate_all();
636 }
526da49c
BI
637
638 _Base&
15ee1a77 639 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
285b36d6 640
526da49c 641 const _Base&
15ee1a77 642 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
285b36d6
BK
643 };
644
957f5fea
VV
645#if __cpp_deduction_guides >= 201606
646 template<typename _InputIterator, typename _ValT
647 = typename iterator_traits<_InputIterator>::value_type,
648 typename _Allocator = allocator<_ValT>,
649 typename = _RequireInputIter<_InputIterator>,
650 typename = _RequireAllocator<_Allocator>>
651 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
652 -> deque<_ValT, _Allocator>;
653#endif
654
285b36d6
BK
655 template<typename _Tp, typename _Alloc>
656 inline bool
526da49c 657 operator==(const deque<_Tp, _Alloc>& __lhs,
285b36d6
BK
658 const deque<_Tp, _Alloc>& __rhs)
659 { return __lhs._M_base() == __rhs._M_base(); }
660
bd2420f8
JW
661#if __cpp_lib_three_way_comparison
662 template<typename _Tp, typename _Alloc>
663 constexpr __detail::__synth3way_t<_Tp>
664 operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
665 { return __x._M_base() <=> __y._M_base(); }
666#else
285b36d6
BK
667 template<typename _Tp, typename _Alloc>
668 inline bool
526da49c 669 operator!=(const deque<_Tp, _Alloc>& __lhs,
285b36d6
BK
670 const deque<_Tp, _Alloc>& __rhs)
671 { return __lhs._M_base() != __rhs._M_base(); }
672
673 template<typename _Tp, typename _Alloc>
674 inline bool
ed540c0a
CJ
675 operator<(const deque<_Tp, _Alloc>& __lhs,
676 const deque<_Tp, _Alloc>& __rhs)
285b36d6
BK
677 { return __lhs._M_base() < __rhs._M_base(); }
678
679 template<typename _Tp, typename _Alloc>
680 inline bool
526da49c 681 operator<=(const deque<_Tp, _Alloc>& __lhs,
285b36d6
BK
682 const deque<_Tp, _Alloc>& __rhs)
683 { return __lhs._M_base() <= __rhs._M_base(); }
684
685 template<typename _Tp, typename _Alloc>
686 inline bool
526da49c 687 operator>=(const deque<_Tp, _Alloc>& __lhs,
285b36d6
BK
688 const deque<_Tp, _Alloc>& __rhs)
689 { return __lhs._M_base() >= __rhs._M_base(); }
690
691 template<typename _Tp, typename _Alloc>
692 inline bool
ed540c0a
CJ
693 operator>(const deque<_Tp, _Alloc>& __lhs,
694 const deque<_Tp, _Alloc>& __rhs)
285b36d6 695 { return __lhs._M_base() > __rhs._M_base(); }
bd2420f8 696#endif // three-way comparison
285b36d6
BK
697
698 template<typename _Tp, typename _Alloc>
699 inline void
700 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
c5d9ec56 701 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
285b36d6 702 { __lhs.swap(__rhs); }
ed540c0a 703
45f388bb 704} // namespace __debug
3cbc7af0 705} // namespace std
285b36d6
BK
706
707#endif