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 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | #ifndef _STL_DEQUE_H |
57 | #define _STL_DEQUE_H 1 |
58 | |
59 | #include <bits/concept_check.h> |
60 | #include <bits/stl_iterator_base_types.h> |
61 | #include <bits/stl_iterator_base_funcs.h> |
62 | #if __cplusplus >= 201103L |
63 | #include <initializer_list> |
64 | #endif |
65 | |
66 | #include <debug/assertions.h> |
67 | |
68 | namespace std _GLIBCXX_VISIBILITY(default) |
69 | { |
70 | _GLIBCXX_BEGIN_NAMESPACE_CONTAINER |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | #ifndef _GLIBCXX_DEQUE_BUF_SIZE |
87 | #define _GLIBCXX_DEQUE_BUF_SIZE 512 |
88 | #endif |
89 | |
90 | _GLIBCXX_CONSTEXPR inline size_t |
91 | __deque_buf_size(size_t __size) |
92 | { return (__size < _GLIBCXX_DEQUE_BUF_SIZE |
93 | ? size_t(_GLIBCXX_DEQUE_BUF_SIZE / __size) : size_t(1)); } |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | template<typename _Tp, typename _Ref, typename _Ptr> |
108 | struct _Deque_iterator |
109 | { |
110 | #if __cplusplus < 201103L |
111 | typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; |
112 | typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; |
113 | typedef _Tp* _Elt_pointer; |
114 | typedef _Tp** _Map_pointer; |
115 | #else |
116 | private: |
117 | template<typename _Up> |
118 | using __ptr_to = typename pointer_traits<_Ptr>::template rebind<_Up>; |
119 | template<typename _CvTp> |
120 | using __iter = _Deque_iterator<_Tp, _CvTp&, __ptr_to<_CvTp>>; |
121 | public: |
122 | typedef __iter<_Tp> iterator; |
123 | typedef __iter<const _Tp> const_iterator; |
124 | typedef __ptr_to<_Tp> _Elt_pointer; |
125 | typedef __ptr_to<_Elt_pointer> _Map_pointer; |
126 | #endif |
127 | |
128 | static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT |
129 | { return __deque_buf_size(sizeof(_Tp)); } |
130 | |
131 | typedef std::random_access_iterator_tag iterator_category; |
132 | typedef _Tp value_type; |
133 | typedef _Ptr pointer; |
134 | typedef _Ref reference; |
135 | typedef size_t size_type; |
136 | typedef ptrdiff_t difference_type; |
137 | typedef _Deque_iterator _Self; |
138 | |
139 | _Elt_pointer _M_cur; |
140 | _Elt_pointer _M_first; |
141 | _Elt_pointer _M_last; |
142 | _Map_pointer _M_node; |
143 | |
144 | _Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT |
145 | : _M_cur(__x), _M_first(*__y), |
146 | _M_last(*__y + _S_buffer_size()), _M_node(__y) { } |
147 | |
148 | _Deque_iterator() _GLIBCXX_NOEXCEPT |
149 | : _M_cur(), _M_first(), _M_last(), _M_node() { } |
150 | |
151 | _Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT |
152 | : _M_cur(__x._M_cur), _M_first(__x._M_first), |
153 | _M_last(__x._M_last), _M_node(__x._M_node) { } |
154 | |
155 | iterator |
156 | _M_const_cast() const _GLIBCXX_NOEXCEPT |
157 | { return iterator(_M_cur, _M_node); } |
158 | |
159 | reference |
160 | operator*() const _GLIBCXX_NOEXCEPT |
161 | { return *_M_cur; } |
162 | |
163 | pointer |
164 | operator->() const _GLIBCXX_NOEXCEPT |
165 | { return _M_cur; } |
166 | |
167 | _Self& |
168 | operator++() _GLIBCXX_NOEXCEPT |
169 | { |
170 | ++_M_cur; |
171 | if (_M_cur == _M_last) |
172 | { |
173 | _M_set_node(_M_node + 1); |
174 | _M_cur = _M_first; |
175 | } |
176 | return *this; |
177 | } |
178 | |
179 | _Self |
180 | operator++(int) _GLIBCXX_NOEXCEPT |
181 | { |
182 | _Self __tmp = *this; |
183 | ++*this; |
184 | return __tmp; |
185 | } |
186 | |
187 | _Self& |
188 | operator--() _GLIBCXX_NOEXCEPT |
189 | { |
190 | if (_M_cur == _M_first) |
191 | { |
192 | _M_set_node(_M_node - 1); |
193 | _M_cur = _M_last; |
194 | } |
195 | --_M_cur; |
196 | return *this; |
197 | } |
198 | |
199 | _Self |
200 | operator--(int) _GLIBCXX_NOEXCEPT |
201 | { |
202 | _Self __tmp = *this; |
203 | --*this; |
204 | return __tmp; |
205 | } |
206 | |
207 | _Self& |
208 | operator+=(difference_type __n) _GLIBCXX_NOEXCEPT |
209 | { |
210 | const difference_type __offset = __n + (_M_cur - _M_first); |
211 | if (__offset >= 0 && __offset < difference_type(_S_buffer_size())) |
212 | _M_cur += __n; |
213 | else |
214 | { |
215 | const difference_type __node_offset = |
216 | __offset > 0 ? __offset / difference_type(_S_buffer_size()) |
217 | : -difference_type((-__offset - 1) |
218 | / _S_buffer_size()) - 1; |
219 | _M_set_node(_M_node + __node_offset); |
220 | _M_cur = _M_first + (__offset - __node_offset |
221 | * difference_type(_S_buffer_size())); |
222 | } |
223 | return *this; |
224 | } |
225 | |
226 | _Self |
227 | operator+(difference_type __n) const _GLIBCXX_NOEXCEPT |
228 | { |
229 | _Self __tmp = *this; |
230 | return __tmp += __n; |
231 | } |
232 | |
233 | _Self& |
234 | operator-=(difference_type __n) _GLIBCXX_NOEXCEPT |
235 | { return *this += -__n; } |
236 | |
237 | _Self |
238 | operator-(difference_type __n) const _GLIBCXX_NOEXCEPT |
239 | { |
240 | _Self __tmp = *this; |
241 | return __tmp -= __n; |
242 | } |
243 | |
244 | reference |
245 | operator[](difference_type __n) const _GLIBCXX_NOEXCEPT |
246 | { return *(*this + __n); } |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | |
253 | void |
254 | _M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT |
255 | { |
256 | _M_node = __new_node; |
257 | _M_first = *__new_node; |
258 | _M_last = _M_first + difference_type(_S_buffer_size()); |
259 | } |
260 | }; |
261 | |
262 | |
263 | |
264 | |
265 | template<typename _Tp, typename _Ref, typename _Ptr> |
266 | inline bool |
267 | operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
268 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
269 | { return __x._M_cur == __y._M_cur; } |
270 | |
271 | template<typename _Tp, typename _RefL, typename _PtrL, |
272 | typename _RefR, typename _PtrR> |
273 | inline bool |
274 | operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
275 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
276 | { return __x._M_cur == __y._M_cur; } |
277 | |
278 | template<typename _Tp, typename _Ref, typename _Ptr> |
279 | inline bool |
280 | operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
281 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
282 | { return !(__x == __y); } |
283 | |
284 | template<typename _Tp, typename _RefL, typename _PtrL, |
285 | typename _RefR, typename _PtrR> |
286 | inline bool |
287 | operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
288 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
289 | { return !(__x == __y); } |
290 | |
291 | template<typename _Tp, typename _Ref, typename _Ptr> |
292 | inline bool |
293 | operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
294 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
295 | { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur) |
296 | : (__x._M_node < __y._M_node); } |
297 | |
298 | template<typename _Tp, typename _RefL, typename _PtrL, |
299 | typename _RefR, typename _PtrR> |
300 | inline bool |
301 | operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
302 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
303 | { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur) |
304 | : (__x._M_node < __y._M_node); } |
305 | |
306 | template<typename _Tp, typename _Ref, typename _Ptr> |
307 | inline bool |
308 | operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
309 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
310 | { return __y < __x; } |
311 | |
312 | template<typename _Tp, typename _RefL, typename _PtrL, |
313 | typename _RefR, typename _PtrR> |
314 | inline bool |
315 | operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
316 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
317 | { return __y < __x; } |
318 | |
319 | template<typename _Tp, typename _Ref, typename _Ptr> |
320 | inline bool |
321 | operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
322 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
323 | { return !(__y < __x); } |
324 | |
325 | template<typename _Tp, typename _RefL, typename _PtrL, |
326 | typename _RefR, typename _PtrR> |
327 | inline bool |
328 | operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
329 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
330 | { return !(__y < __x); } |
331 | |
332 | template<typename _Tp, typename _Ref, typename _Ptr> |
333 | inline bool |
334 | operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
335 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
336 | { return !(__x < __y); } |
337 | |
338 | template<typename _Tp, typename _RefL, typename _PtrL, |
339 | typename _RefR, typename _PtrR> |
340 | inline bool |
341 | operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
342 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
343 | { return !(__x < __y); } |
344 | |
345 | |
346 | |
347 | |
348 | |
349 | template<typename _Tp, typename _Ref, typename _Ptr> |
350 | inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type |
351 | operator-(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, |
352 | const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT |
353 | { |
354 | return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type |
355 | (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size()) |
356 | * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) |
357 | + (__y._M_last - __y._M_cur); |
358 | } |
359 | |
360 | template<typename _Tp, typename _RefL, typename _PtrL, |
361 | typename _RefR, typename _PtrR> |
362 | inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type |
363 | operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, |
364 | const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT |
365 | { |
366 | return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type |
367 | (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size()) |
368 | * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) |
369 | + (__y._M_last - __y._M_cur); |
370 | } |
371 | |
372 | template<typename _Tp, typename _Ref, typename _Ptr> |
373 | inline _Deque_iterator<_Tp, _Ref, _Ptr> |
374 | operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x) |
375 | _GLIBCXX_NOEXCEPT |
376 | { return __x + __n; } |
377 | |
378 | template<typename _Tp> |
379 | void |
380 | fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>&, |
381 | const _Deque_iterator<_Tp, _Tp&, _Tp*>&, const _Tp&); |
382 | |
383 | template<typename _Tp> |
384 | _Deque_iterator<_Tp, _Tp&, _Tp*> |
385 | copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
386 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
387 | _Deque_iterator<_Tp, _Tp&, _Tp*>); |
388 | |
389 | template<typename _Tp> |
390 | inline _Deque_iterator<_Tp, _Tp&, _Tp*> |
391 | copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, |
392 | _Deque_iterator<_Tp, _Tp&, _Tp*> __last, |
393 | _Deque_iterator<_Tp, _Tp&, _Tp*> __result) |
394 | { return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first), |
395 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last), |
396 | __result); } |
397 | |
398 | template<typename _Tp> |
399 | _Deque_iterator<_Tp, _Tp&, _Tp*> |
400 | copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
401 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
402 | _Deque_iterator<_Tp, _Tp&, _Tp*>); |
403 | |
404 | template<typename _Tp> |
405 | inline _Deque_iterator<_Tp, _Tp&, _Tp*> |
406 | copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, |
407 | _Deque_iterator<_Tp, _Tp&, _Tp*> __last, |
408 | _Deque_iterator<_Tp, _Tp&, _Tp*> __result) |
409 | { return std::copy_backward(_Deque_iterator<_Tp, |
410 | const _Tp&, const _Tp*>(__first), |
411 | _Deque_iterator<_Tp, |
412 | const _Tp&, const _Tp*>(__last), |
413 | __result); } |
414 | |
415 | #if __cplusplus >= 201103L |
416 | template<typename _Tp> |
417 | _Deque_iterator<_Tp, _Tp&, _Tp*> |
418 | move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
419 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
420 | _Deque_iterator<_Tp, _Tp&, _Tp*>); |
421 | |
422 | template<typename _Tp> |
423 | inline _Deque_iterator<_Tp, _Tp&, _Tp*> |
424 | move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, |
425 | _Deque_iterator<_Tp, _Tp&, _Tp*> __last, |
426 | _Deque_iterator<_Tp, _Tp&, _Tp*> __result) |
427 | { return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first), |
428 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last), |
429 | __result); } |
430 | |
431 | template<typename _Tp> |
432 | _Deque_iterator<_Tp, _Tp&, _Tp*> |
433 | move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
434 | _Deque_iterator<_Tp, const _Tp&, const _Tp*>, |
435 | _Deque_iterator<_Tp, _Tp&, _Tp*>); |
436 | |
437 | template<typename _Tp> |
438 | inline _Deque_iterator<_Tp, _Tp&, _Tp*> |
439 | move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first, |
440 | _Deque_iterator<_Tp, _Tp&, _Tp*> __last, |
441 | _Deque_iterator<_Tp, _Tp&, _Tp*> __result) |
442 | { return std::move_backward(_Deque_iterator<_Tp, |
443 | const _Tp&, const _Tp*>(__first), |
444 | _Deque_iterator<_Tp, |
445 | const _Tp&, const _Tp*>(__last), |
446 | __result); } |
447 | #endif |
448 | |
449 | |
450 | |
451 | |
452 | |
453 | |
454 | |
455 | |
456 | |
457 | |
458 | |
459 | template<typename _Tp, typename _Alloc> |
460 | class _Deque_base |
461 | { |
462 | protected: |
463 | typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template |
464 | rebind<_Tp>::other _Tp_alloc_type; |
465 | typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; |
466 | |
467 | #if __cplusplus < 201103L |
468 | typedef _Tp* _Ptr; |
469 | typedef const _Tp* _Ptr_const; |
470 | #else |
471 | typedef typename _Alloc_traits::pointer _Ptr; |
472 | typedef typename _Alloc_traits::const_pointer _Ptr_const; |
473 | #endif |
474 | |
475 | typedef typename _Alloc_traits::template rebind<_Ptr>::other |
476 | _Map_alloc_type; |
477 | typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits; |
478 | |
479 | public: |
480 | typedef _Alloc allocator_type; |
481 | typedef typename _Alloc_traits::size_type size_type; |
482 | |
483 | allocator_type |
484 | get_allocator() const _GLIBCXX_NOEXCEPT |
485 | { return allocator_type(_M_get_Tp_allocator()); } |
486 | |
487 | typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator; |
488 | typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator; |
489 | |
490 | _Deque_base() |
491 | : _M_impl() |
492 | { _M_initialize_map(0); } |
493 | |
494 | _Deque_base(size_t __num_elements) |
495 | : _M_impl() |
496 | { _M_initialize_map(__num_elements); } |
497 | |
498 | _Deque_base(const allocator_type& __a, size_t __num_elements) |
499 | : _M_impl(__a) |
500 | { _M_initialize_map(__num_elements); } |
501 | |
502 | _Deque_base(const allocator_type& __a) |
503 | : _M_impl(__a) |
504 | { } |
505 | |
506 | #if __cplusplus >= 201103L |
507 | _Deque_base(_Deque_base&& __x, false_type) |
508 | : _M_impl(__x._M_move_impl()) |
509 | { } |
510 | |
511 | _Deque_base(_Deque_base&& __x, true_type) |
512 | : _M_impl(std::move(__x._M_get_Tp_allocator())) |
513 | { |
514 | _M_initialize_map(0); |
515 | if (__x._M_impl._M_map) |
516 | this->_M_impl._M_swap_data(__x._M_impl); |
517 | } |
518 | |
519 | _Deque_base(_Deque_base&& __x) |
520 | : _Deque_base(std::move(__x), typename _Alloc_traits::is_always_equal{}) |
521 | { } |
522 | |
523 | _Deque_base(_Deque_base&& __x, const allocator_type& __a, size_type __n) |
524 | : _M_impl(__a) |
525 | { |
526 | if (__x.get_allocator() == __a) |
527 | { |
528 | if (__x._M_impl._M_map) |
529 | { |
530 | _M_initialize_map(0); |
531 | this->_M_impl._M_swap_data(__x._M_impl); |
532 | } |
533 | } |
534 | else |
535 | { |
536 | _M_initialize_map(__n); |
537 | } |
538 | } |
539 | #endif |
540 | |
541 | ~_Deque_base() _GLIBCXX_NOEXCEPT; |
542 | |
543 | protected: |
544 | typedef typename iterator::_Map_pointer _Map_pointer; |
545 | |
546 | |
547 | |
548 | |
549 | struct _Deque_impl |
550 | : public _Tp_alloc_type |
551 | { |
552 | _Map_pointer _M_map; |
553 | size_t _M_map_size; |
554 | iterator _M_start; |
555 | iterator _M_finish; |
556 | |
557 | _Deque_impl() |
558 | : _Tp_alloc_type(), _M_map(), _M_map_size(0), |
559 | _M_start(), _M_finish() |
560 | { } |
561 | |
562 | _Deque_impl(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT |
563 | : _Tp_alloc_type(__a), _M_map(), _M_map_size(0), |
564 | _M_start(), _M_finish() |
565 | { } |
566 | |
567 | #if __cplusplus >= 201103L |
568 | _Deque_impl(_Deque_impl&&) = default; |
569 | |
570 | _Deque_impl(_Tp_alloc_type&& __a) noexcept |
571 | : _Tp_alloc_type(std::move(__a)), _M_map(), _M_map_size(0), |
572 | _M_start(), _M_finish() |
573 | { } |
574 | #endif |
575 | |
576 | void _M_swap_data(_Deque_impl& __x) _GLIBCXX_NOEXCEPT |
577 | { |
578 | using std::swap; |
579 | swap(this->_M_start, __x._M_start); |
580 | swap(this->_M_finish, __x._M_finish); |
581 | swap(this->_M_map, __x._M_map); |
582 | swap(this->_M_map_size, __x._M_map_size); |
583 | } |
584 | }; |
585 | |
586 | _Tp_alloc_type& |
587 | _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT |
588 | { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); } |
589 | |
590 | const _Tp_alloc_type& |
591 | _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT |
592 | { return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); } |
593 | |
594 | _Map_alloc_type |
595 | _M_get_map_allocator() const _GLIBCXX_NOEXCEPT |
596 | { return _Map_alloc_type(_M_get_Tp_allocator()); } |
597 | |
598 | _Ptr |
599 | _M_allocate_node() |
600 | { |
601 | typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; |
602 | return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp))); |
603 | } |
604 | |
605 | void |
606 | _M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT |
607 | { |
608 | typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; |
609 | _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp))); |
610 | } |
611 | |
612 | _Map_pointer |
613 | _M_allocate_map(size_t __n) |
614 | { |
615 | _Map_alloc_type __map_alloc = _M_get_map_allocator(); |
616 | return _Map_alloc_traits::allocate(__map_alloc, __n); |
617 | } |
618 | |
619 | void |
620 | _M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT |
621 | { |
622 | _Map_alloc_type __map_alloc = _M_get_map_allocator(); |
623 | _Map_alloc_traits::deallocate(__map_alloc, __p, __n); |
624 | } |
625 | |
626 | protected: |
627 | void _M_initialize_map(size_t); |
628 | void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish); |
629 | void _M_destroy_nodes(_Map_pointer __nstart, |
630 | _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT; |
631 | enum { _S_initial_map_size = 8 }; |
632 | |
633 | _Deque_impl _M_impl; |
634 | |
635 | #if __cplusplus >= 201103L |
636 | private: |
637 | _Deque_impl |
638 | _M_move_impl() |
639 | { |
640 | if (!_M_impl._M_map) |
641 | return std::move(_M_impl); |
642 | |
643 | |
644 | _Tp_alloc_type __alloc{_M_get_Tp_allocator()}; |
645 | |
646 | _Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)}; |
647 | |
648 | _Deque_base __empty{__alloc}; |
649 | __empty._M_initialize_map(0); |
650 | |
651 | _Deque_impl __ret{std::move(_M_get_Tp_allocator())}; |
652 | _M_impl._M_swap_data(__ret); |
653 | _M_impl._M_swap_data(__empty._M_impl); |
654 | return __ret; |
655 | } |
656 | #endif |
657 | }; |
658 | |
659 | template<typename _Tp, typename _Alloc> |
660 | _Deque_base<_Tp, _Alloc>:: |
661 | ~_Deque_base() _GLIBCXX_NOEXCEPT |
662 | { |
663 | if (this->_M_impl._M_map) |
664 | { |
665 | _M_destroy_nodes(this->_M_impl._M_start._M_node, |
666 | this->_M_impl._M_finish._M_node + 1); |
667 | _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); |
668 | } |
669 | } |
670 | |
671 | |
672 | |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | |
679 | template<typename _Tp, typename _Alloc> |
680 | void |
681 | _Deque_base<_Tp, _Alloc>:: |
682 | _M_initialize_map(size_t __num_elements) |
683 | { |
684 | const size_t __num_nodes = (__num_elements/ __deque_buf_size(sizeof(_Tp)) |
685 | + 1); |
686 | |
687 | this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size, |
688 | size_t(__num_nodes + 2)); |
689 | this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); |
690 | |
691 | |
692 | |
693 | |
694 | |
695 | |
696 | _Map_pointer __nstart = (this->_M_impl._M_map |
697 | + (this->_M_impl._M_map_size - __num_nodes) / 2); |
698 | _Map_pointer __nfinish = __nstart + __num_nodes; |
699 | |
700 | __try |
701 | { _M_create_nodes(__nstart, __nfinish); } |
702 | __catch(...) |
703 | { |
704 | _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); |
705 | this->_M_impl._M_map = _Map_pointer(); |
706 | this->_M_impl._M_map_size = 0; |
707 | __throw_exception_again; |
708 | } |
709 | |
710 | this->_M_impl._M_start._M_set_node(__nstart); |
711 | this->_M_impl._M_finish._M_set_node(__nfinish - 1); |
712 | this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first; |
713 | this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first |
714 | + __num_elements |
715 | % __deque_buf_size(sizeof(_Tp))); |
716 | } |
717 | |
718 | template<typename _Tp, typename _Alloc> |
719 | void |
720 | _Deque_base<_Tp, _Alloc>:: |
721 | _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) |
722 | { |
723 | _Map_pointer __cur; |
724 | __try |
725 | { |
726 | for (__cur = __nstart; __cur < __nfinish; ++__cur) |
727 | *__cur = this->_M_allocate_node(); |
728 | } |
729 | __catch(...) |
730 | { |
731 | _M_destroy_nodes(__nstart, __cur); |
732 | __throw_exception_again; |
733 | } |
734 | } |
735 | |
736 | template<typename _Tp, typename _Alloc> |
737 | void |
738 | _Deque_base<_Tp, _Alloc>:: |
739 | _M_destroy_nodes(_Map_pointer __nstart, |
740 | _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT |
741 | { |
742 | for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n) |
743 | _M_deallocate_node(*__n); |
744 | } |
745 | |
746 | |
747 | |
748 | |
749 | |
750 | |
751 | |
752 | |
753 | |
754 | |
755 | |
756 | |
757 | |
758 | |
759 | |
760 | |
761 | |
762 | |
763 | |
764 | |
765 | |
766 | |
767 | |
768 | |
769 | |
770 | |
771 | |
772 | |
773 | |
774 | |
775 | |
776 | |
777 | |
778 | |
779 | |
780 | |
781 | |
782 | |
783 | |
784 | |
785 | |
786 | |
787 | |
788 | |
789 | |
790 | |
791 | |
792 | |
793 | |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | |
800 | |
801 | |
802 | |
803 | |
804 | |
805 | |
806 | |
807 | |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | |
814 | |
815 | |
816 | |
817 | |
818 | |
819 | |
820 | |
821 | |
822 | |
823 | |
824 | |
825 | |
826 | |
827 | |
828 | |
829 | |
830 | template<typename _Tp, typename _Alloc = std::allocator<_Tp> > |
831 | class deque : protected _Deque_base<_Tp, _Alloc> |
832 | { |
833 | #ifdef _GLIBCXX_CONCEPT_CHECKS |
834 | |
835 | typedef typename _Alloc::value_type _Alloc_value_type; |
836 | # if __cplusplus < 201103L |
837 | __glibcxx_class_requires(_Tp, _SGIAssignableConcept) |
838 | # endif |
839 | __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) |
840 | #endif |
841 | |
842 | typedef _Deque_base<_Tp, _Alloc> _Base; |
843 | typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; |
844 | typedef typename _Base::_Alloc_traits _Alloc_traits; |
845 | typedef typename _Base::_Map_pointer _Map_pointer; |
846 | |
847 | public: |
848 | typedef _Tp value_type; |
849 | typedef typename _Alloc_traits::pointer pointer; |
850 | typedef typename _Alloc_traits::const_pointer const_pointer; |
851 | typedef typename _Alloc_traits::reference reference; |
852 | typedef typename _Alloc_traits::const_reference const_reference; |
853 | typedef typename _Base::iterator iterator; |
854 | typedef typename _Base::const_iterator const_iterator; |
855 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
856 | typedef std::reverse_iterator<iterator> reverse_iterator; |
857 | typedef size_t size_type; |
858 | typedef ptrdiff_t difference_type; |
859 | typedef _Alloc allocator_type; |
860 | |
861 | protected: |
862 | static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT |
863 | { return __deque_buf_size(sizeof(_Tp)); } |
864 | |
865 | |
866 | using _Base::_M_initialize_map; |
867 | using _Base::_M_create_nodes; |
868 | using _Base::_M_destroy_nodes; |
869 | using _Base::_M_allocate_node; |
870 | using _Base::_M_deallocate_node; |
871 | using _Base::_M_allocate_map; |
872 | using _Base::_M_deallocate_map; |
873 | using _Base::_M_get_Tp_allocator; |
874 | |
875 | |
876 | |
877 | |
878 | |
879 | using _Base::_M_impl; |
880 | |
881 | public: |
882 | |
883 | |
884 | |
885 | |
886 | |
887 | |
888 | deque() : _Base() { } |
889 | |
890 | |
891 | |
892 | |
893 | |
894 | explicit |
895 | deque(const allocator_type& __a) |
896 | : _Base(__a, 0) { } |
897 | |
898 | #if __cplusplus >= 201103L |
899 | |
900 | |
901 | |
902 | |
903 | |
904 | |
905 | |
906 | |
907 | explicit |
908 | deque(size_type __n, const allocator_type& __a = allocator_type()) |
909 | : _Base(__a, __n) |
910 | { _M_default_initialize(); } |
911 | |
912 | |
913 | |
914 | |
915 | |
916 | |
917 | |
918 | |
919 | |
920 | deque(size_type __n, const value_type& __value, |
921 | const allocator_type& __a = allocator_type()) |
922 | : _Base(__a, __n) |
923 | { _M_fill_initialize(__value); } |
924 | #else |
925 | |
926 | |
927 | |
928 | |
929 | |
930 | |
931 | |
932 | |
933 | explicit |
934 | deque(size_type __n, const value_type& __value = value_type(), |
935 | const allocator_type& __a = allocator_type()) |
936 | : _Base(__a, __n) |
937 | { _M_fill_initialize(__value); } |
938 | #endif |
939 | |
940 | |
941 | |
942 | |
943 | |
944 | |
945 | |
946 | |
947 | deque(const deque& __x) |
948 | : _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()), |
949 | __x.size()) |
950 | { std::__uninitialized_copy_a(__x.begin(), __x.end(), |
951 | this->_M_impl._M_start, |
952 | _M_get_Tp_allocator()); } |
953 | |
954 | #if __cplusplus >= 201103L |
955 | |
956 | |
957 | |
958 | |
959 | |
960 | |
961 | |
962 | deque(deque&& __x) |
963 | : _Base(std::move(__x)) { } |
964 | |
965 | |
966 | deque(const deque& __x, const allocator_type& __a) |
967 | : _Base(__a, __x.size()) |
968 | { std::__uninitialized_copy_a(__x.begin(), __x.end(), |
969 | this->_M_impl._M_start, |
970 | _M_get_Tp_allocator()); } |
971 | |
972 | |
973 | deque(deque&& __x, const allocator_type& __a) |
974 | : _Base(std::move(__x), __a, __x.size()) |
975 | { |
976 | if (__x.get_allocator() != __a) |
977 | { |
978 | std::__uninitialized_move_a(__x.begin(), __x.end(), |
979 | this->_M_impl._M_start, |
980 | _M_get_Tp_allocator()); |
981 | __x.clear(); |
982 | } |
983 | } |
984 | |
985 | |
986 | |
987 | |
988 | |
989 | |
990 | |
991 | |
992 | |
993 | |
994 | |
995 | |
996 | deque(initializer_list<value_type> __l, |
997 | const allocator_type& __a = allocator_type()) |
998 | : _Base(__a) |
999 | { |
1000 | _M_range_initialize(__l.begin(), __l.end(), |
1001 | random_access_iterator_tag()); |
1002 | } |
1003 | #endif |
1004 | |
1005 | |
1006 | |
1007 | |
1008 | |
1009 | |
1010 | |
1011 | |
1012 | |
1013 | |
1014 | |
1015 | |
1016 | |
1017 | |
1018 | |
1019 | |
1020 | #if __cplusplus >= 201103L |
1021 | template<typename _InputIterator, |
1022 | typename = std::_RequireInputIter<_InputIterator>> |
1023 | deque(_InputIterator __first, _InputIterator __last, |
1024 | const allocator_type& __a = allocator_type()) |
1025 | : _Base(__a) |
1026 | { _M_initialize_dispatch(__first, __last, __false_type()); } |
1027 | #else |
1028 | template<typename _InputIterator> |
1029 | deque(_InputIterator __first, _InputIterator __last, |
1030 | const allocator_type& __a = allocator_type()) |
1031 | : _Base(__a) |
1032 | { |
1033 | |
1034 | typedef typename std::__is_integer<_InputIterator>::__type _Integral; |
1035 | _M_initialize_dispatch(__first, __last, _Integral()); |
1036 | } |
1037 | #endif |
1038 | |
1039 | |
1040 | |
1041 | |
1042 | |
1043 | |
1044 | ~deque() |
1045 | { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); } |
1046 | |
1047 | |
1048 | |
1049 | |
1050 | |
1051 | |
1052 | |
1053 | |
1054 | |
1055 | |
1056 | deque& |
1057 | operator=(const deque& __x); |
1058 | |
1059 | #if __cplusplus >= 201103L |
1060 | |
1061 | |
1062 | |
1063 | |
1064 | |
1065 | |
1066 | |
1067 | |
1068 | deque& |
1069 | operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal()) |
1070 | { |
1071 | using __always_equal = typename _Alloc_traits::is_always_equal; |
1072 | _M_move_assign1(std::move(__x), __always_equal{}); |
1073 | return *this; |
1074 | } |
1075 | |
1076 | |
1077 | |
1078 | |
1079 | |
1080 | |
1081 | |
1082 | |
1083 | |
1084 | |
1085 | |
1086 | |
1087 | deque& |
1088 | operator=(initializer_list<value_type> __l) |
1089 | { |
1090 | _M_assign_aux(__l.begin(), __l.end(), |
1091 | random_access_iterator_tag()); |
1092 | return *this; |
1093 | } |
1094 | #endif |
1095 | |
1096 | |
1097 | |
1098 | |
1099 | |
1100 | |
1101 | |
1102 | |
1103 | |
1104 | |
1105 | |
1106 | void |
1107 | assign(size_type __n, const value_type& __val) |
1108 | { _M_fill_assign(__n, __val); } |
1109 | |
1110 | |
1111 | |
1112 | |
1113 | |
1114 | |
1115 | |
1116 | |
1117 | |
1118 | |
1119 | |
1120 | |
1121 | |
1122 | #if __cplusplus >= 201103L |
1123 | template<typename _InputIterator, |
1124 | typename = std::_RequireInputIter<_InputIterator>> |
1125 | void |
1126 | assign(_InputIterator __first, _InputIterator __last) |
1127 | { _M_assign_dispatch(__first, __last, __false_type()); } |
1128 | #else |
1129 | template<typename _InputIterator> |
1130 | void |
1131 | assign(_InputIterator __first, _InputIterator __last) |
1132 | { |
1133 | typedef typename std::__is_integer<_InputIterator>::__type _Integral; |
1134 | _M_assign_dispatch(__first, __last, _Integral()); |
1135 | } |
1136 | #endif |
1137 | |
1138 | #if __cplusplus >= 201103L |
1139 | |
1140 | |
1141 | |
1142 | |
1143 | |
1144 | |
1145 | |
1146 | |
1147 | |
1148 | |
1149 | |
1150 | void |
1151 | assign(initializer_list<value_type> __l) |
1152 | { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } |
1153 | #endif |
1154 | |
1155 | |
1156 | allocator_type |
1157 | get_allocator() const _GLIBCXX_NOEXCEPT |
1158 | { return _Base::get_allocator(); } |
1159 | |
1160 | |
1161 | |
1162 | |
1163 | |
1164 | |
1165 | iterator |
1166 | begin() _GLIBCXX_NOEXCEPT |
1167 | { return this->_M_impl._M_start; } |
1168 | |
1169 | |
1170 | |
1171 | |
1172 | |
1173 | const_iterator |
1174 | begin() const _GLIBCXX_NOEXCEPT |
1175 | { return this->_M_impl._M_start; } |
1176 | |
1177 | |
1178 | |
1179 | |
1180 | |
1181 | |
1182 | iterator |
1183 | end() _GLIBCXX_NOEXCEPT |
1184 | { return this->_M_impl._M_finish; } |
1185 | |
1186 | |
1187 | |
1188 | |
1189 | |
1190 | |
1191 | const_iterator |
1192 | end() const _GLIBCXX_NOEXCEPT |
1193 | { return this->_M_impl._M_finish; } |
1194 | |
1195 | |
1196 | |
1197 | |
1198 | |
1199 | |
1200 | reverse_iterator |
1201 | rbegin() _GLIBCXX_NOEXCEPT |
1202 | { return reverse_iterator(this->_M_impl._M_finish); } |
1203 | |
1204 | |
1205 | |
1206 | |
1207 | |
1208 | |
1209 | const_reverse_iterator |
1210 | rbegin() const _GLIBCXX_NOEXCEPT |
1211 | { return const_reverse_iterator(this->_M_impl._M_finish); } |
1212 | |
1213 | |
1214 | |
1215 | |
1216 | |
1217 | |
1218 | reverse_iterator |
1219 | rend() _GLIBCXX_NOEXCEPT |
1220 | { return reverse_iterator(this->_M_impl._M_start); } |
1221 | |
1222 | |
1223 | |
1224 | |
1225 | |
1226 | |
1227 | const_reverse_iterator |
1228 | rend() const _GLIBCXX_NOEXCEPT |
1229 | { return const_reverse_iterator(this->_M_impl._M_start); } |
1230 | |
1231 | #if __cplusplus >= 201103L |
1232 | |
1233 | |
1234 | |
1235 | |
1236 | const_iterator |
1237 | cbegin() const noexcept |
1238 | { return this->_M_impl._M_start; } |
1239 | |
1240 | |
1241 | |
1242 | |
1243 | |
1244 | |
1245 | const_iterator |
1246 | cend() const noexcept |
1247 | { return this->_M_impl._M_finish; } |
1248 | |
1249 | |
1250 | |
1251 | |
1252 | |
1253 | |
1254 | const_reverse_iterator |
1255 | crbegin() const noexcept |
1256 | { return const_reverse_iterator(this->_M_impl._M_finish); } |
1257 | |
1258 | |
1259 | |
1260 | |
1261 | |
1262 | |
1263 | const_reverse_iterator |
1264 | crend() const noexcept |
1265 | { return const_reverse_iterator(this->_M_impl._M_start); } |
1266 | #endif |
1267 | |
1268 | |
1269 | |
1270 | size_type |
1271 | size() const _GLIBCXX_NOEXCEPT |
1272 | { return this->_M_impl._M_finish - this->_M_impl._M_start; } |
1273 | |
1274 | |
1275 | size_type |
1276 | max_size() const _GLIBCXX_NOEXCEPT |
1277 | { return _Alloc_traits::max_size(_M_get_Tp_allocator()); } |
1278 | |
1279 | #if __cplusplus >= 201103L |
1280 | |
1281 | |
1282 | |
1283 | |
1284 | |
1285 | |
1286 | |
1287 | |
1288 | |
1289 | void |
1290 | resize(size_type __new_size) |
1291 | { |
1292 | const size_type __len = size(); |
1293 | if (__new_size > __len) |
1294 | _M_default_append(__new_size - __len); |
1295 | else if (__new_size < __len) |
1296 | _M_erase_at_end(this->_M_impl._M_start |
1297 | + difference_type(__new_size)); |
1298 | } |
1299 | |
1300 | |
1301 | |
1302 | |
1303 | |
1304 | |
1305 | |
1306 | |
1307 | |
1308 | |
1309 | |
1310 | |
1311 | void |
1312 | resize(size_type __new_size, const value_type& __x) |
1313 | { |
1314 | const size_type __len = size(); |
1315 | if (__new_size > __len) |
1316 | _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); |
1317 | else if (__new_size < __len) |
1318 | _M_erase_at_end(this->_M_impl._M_start |
1319 | + difference_type(__new_size)); |
1320 | } |
1321 | #else |
1322 | |
1323 | |
1324 | |
1325 | |
1326 | |
1327 | |
1328 | |
1329 | |
1330 | |
1331 | |
1332 | |
1333 | void |
1334 | resize(size_type __new_size, value_type __x = value_type()) |
1335 | { |
1336 | const size_type __len = size(); |
1337 | if (__new_size > __len) |
1338 | _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); |
1339 | else if (__new_size < __len) |
1340 | _M_erase_at_end(this->_M_impl._M_start |
1341 | + difference_type(__new_size)); |
1342 | } |
1343 | #endif |
1344 | |
1345 | #if __cplusplus >= 201103L |
1346 | |
1347 | void |
1348 | shrink_to_fit() noexcept |
1349 | { _M_shrink_to_fit(); } |
1350 | #endif |
1351 | |
1352 | |
1353 | |
1354 | |
1355 | |
1356 | bool |
1357 | empty() const _GLIBCXX_NOEXCEPT |
1358 | { return this->_M_impl._M_finish == this->_M_impl._M_start; } |
1359 | |
1360 | |
1361 | |
1362 | |
1363 | |
1364 | |
1365 | |
1366 | |
1367 | |
1368 | |
1369 | |
1370 | |
1371 | |
1372 | reference |
1373 | operator[](size_type __n) _GLIBCXX_NOEXCEPT |
1374 | { |
1375 | __glibcxx_requires_subscript(__n); |
1376 | return this->_M_impl._M_start[difference_type(__n)]; |
1377 | } |
1378 | |
1379 | |
1380 | |
1381 | |
1382 | |
1383 | |
1384 | |
1385 | |
1386 | |
1387 | |
1388 | |
1389 | |
1390 | const_reference |
1391 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT |
1392 | { |
1393 | __glibcxx_requires_subscript(__n); |
1394 | return this->_M_impl._M_start[difference_type(__n)]; |
1395 | } |
1396 | |
1397 | protected: |
1398 | |
1399 | void |
1400 | _M_range_check(size_type __n) const |
1401 | { |
1402 | if (__n >= this->size()) |
1403 | __throw_out_of_range_fmt(= this->size() " "(which is %zu)")" file_link="../../../x86_64-linux-gnu/c++/7/bits/c++config.h.html#595" macro="true">__N("deque::_M_range_check: __n " |
1404 | = this->size() " "(which is %zu)")" file_link="../../../x86_64-linux-gnu/c++/7/bits/c++config.h.html#595" macro="true"> "(which is %zu)>= this->size() " |
1405 | = this->size() " "(which is %zu)")" file_link="../../../x86_64-linux-gnu/c++/7/bits/c++config.h.html#595" macro="true"> "(which is %zu)"), |
1406 | __n, this->size()); |
1407 | } |
1408 | |
1409 | public: |
1410 | |
1411 | |
1412 | |
1413 | |
1414 | |
1415 | |
1416 | |
1417 | |
1418 | |
1419 | |
1420 | |
1421 | reference |
1422 | at(size_type __n) |
1423 | { |
1424 | _M_range_check(__n); |
1425 | return (*this)[__n]; |
1426 | } |
1427 | |
1428 | |
1429 | |
1430 | |
1431 | |
1432 | |
1433 | |
1434 | |
1435 | |
1436 | |
1437 | |
1438 | |
1439 | const_reference |
1440 | at(size_type __n) const |
1441 | { |
1442 | _M_range_check(__n); |
1443 | return (*this)[__n]; |
1444 | } |
1445 | |
1446 | |
1447 | |
1448 | |
1449 | |
1450 | reference |
1451 | front() _GLIBCXX_NOEXCEPT |
1452 | { |
1453 | __glibcxx_requires_nonempty(); |
1454 | return *begin(); |
1455 | } |
1456 | |
1457 | |
1458 | |
1459 | |
1460 | |
1461 | const_reference |
1462 | front() const _GLIBCXX_NOEXCEPT |
1463 | { |
1464 | __glibcxx_requires_nonempty(); |
1465 | return *begin(); |
1466 | } |
1467 | |
1468 | |
1469 | |
1470 | |
1471 | |
1472 | reference |
1473 | back() _GLIBCXX_NOEXCEPT |
1474 | { |
1475 | __glibcxx_requires_nonempty(); |
1476 | iterator __tmp = end(); |
1477 | --__tmp; |
1478 | return *__tmp; |
1479 | } |
1480 | |
1481 | |
1482 | |
1483 | |
1484 | |
1485 | const_reference |
1486 | back() const _GLIBCXX_NOEXCEPT |
1487 | { |
1488 | __glibcxx_requires_nonempty(); |
1489 | const_iterator __tmp = end(); |
1490 | --__tmp; |
1491 | return *__tmp; |
1492 | } |
1493 | |
1494 | |
1495 | |
1496 | |
1497 | |
1498 | |
1499 | |
1500 | |
1501 | |
1502 | |
1503 | |
1504 | void |
1505 | push_front(const value_type& __x) |
1506 | { |
1507 | if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) |
1508 | { |
1509 | _Alloc_traits::construct(this->_M_impl, |
1510 | this->_M_impl._M_start._M_cur - 1, |
1511 | __x); |
1512 | --this->_M_impl._M_start._M_cur; |
1513 | } |
1514 | else |
1515 | _M_push_front_aux(__x); |
1516 | } |
1517 | |
1518 | #if __cplusplus >= 201103L |
1519 | void |
1520 | push_front(value_type&& __x) |
1521 | { emplace_front(std::move(__x)); } |
1522 | |
1523 | template<typename... _Args> |
1524 | #if __cplusplus > 201402L |
1525 | reference |
1526 | #else |
1527 | void |
1528 | #endif |
1529 | emplace_front(_Args&&... __args); |
1530 | #endif |
1531 | |
1532 | |
1533 | |
1534 | |
1535 | |
1536 | |
1537 | |
1538 | |
1539 | |
1540 | |
1541 | void |
1542 | push_back(const value_type& __x) |
1543 | { |
1544 | if (this->_M_impl._M_finish._M_cur |
1545 | != this->_M_impl._M_finish._M_last - 1) |
1546 | { |
1547 | _Alloc_traits::construct(this->_M_impl, |
1548 | this->_M_impl._M_finish._M_cur, __x); |
1549 | ++this->_M_impl._M_finish._M_cur; |
1550 | } |
1551 | else |
1552 | _M_push_back_aux(__x); |
1553 | } |
1554 | |
1555 | #if __cplusplus >= 201103L |
1556 | void |
1557 | push_back(value_type&& __x) |
1558 | { emplace_back(std::move(__x)); } |
1559 | |
1560 | template<typename... _Args> |
1561 | #if __cplusplus > 201402L |
1562 | reference |
1563 | #else |
1564 | void |
1565 | #endif |
1566 | emplace_back(_Args&&... __args); |
1567 | #endif |
1568 | |
1569 | |
1570 | |
1571 | |
1572 | |
1573 | |
1574 | |
1575 | |
1576 | |
1577 | void |
1578 | pop_front() _GLIBCXX_NOEXCEPT |
1579 | { |
1580 | __glibcxx_requires_nonempty(); |
1581 | if (this->_M_impl._M_start._M_cur |
1582 | != this->_M_impl._M_start._M_last - 1) |
1583 | { |
1584 | _Alloc_traits::destroy(this->_M_impl, |
1585 | this->_M_impl._M_start._M_cur); |
1586 | ++this->_M_impl._M_start._M_cur; |
1587 | } |
1588 | else |
1589 | _M_pop_front_aux(); |
1590 | } |
1591 | |
1592 | |
1593 | |
1594 | |
1595 | |
1596 | |
1597 | |
1598 | |
1599 | |
1600 | void |
1601 | pop_back() _GLIBCXX_NOEXCEPT |
1602 | { |
1603 | __glibcxx_requires_nonempty(); |
1604 | if (this->_M_impl._M_finish._M_cur |
1605 | != this->_M_impl._M_finish._M_first) |
1606 | { |
1607 | --this->_M_impl._M_finish._M_cur; |
1608 | _Alloc_traits::destroy(this->_M_impl, |
1609 | this->_M_impl._M_finish._M_cur); |
1610 | } |
1611 | else |
1612 | _M_pop_back_aux(); |
1613 | } |
1614 | |
1615 | #if __cplusplus >= 201103L |
1616 | |
1617 | |
1618 | |
1619 | |
1620 | |
1621 | |
1622 | |
1623 | |
1624 | |
1625 | template<typename... _Args> |
1626 | iterator |
1627 | emplace(const_iterator __position, _Args&&... __args); |
1628 | |
1629 | |
1630 | |
1631 | |
1632 | |
1633 | |
1634 | |
1635 | |
1636 | |
1637 | |
1638 | iterator |
1639 | insert(const_iterator __position, const value_type& __x); |
1640 | #else |
1641 | |
1642 | |
1643 | |
1644 | |
1645 | |
1646 | |
1647 | |
1648 | |
1649 | |
1650 | iterator |
1651 | insert(iterator __position, const value_type& __x); |
1652 | #endif |
1653 | |
1654 | #if __cplusplus >= 201103L |
1655 | |
1656 | |
1657 | |
1658 | |
1659 | |
1660 | |
1661 | |
1662 | |
1663 | |
1664 | iterator |
1665 | insert(const_iterator __position, value_type&& __x) |
1666 | { return emplace(__position, std::move(__x)); } |
1667 | |
1668 | |
1669 | |
1670 | |
1671 | |
1672 | |
1673 | |
1674 | |
1675 | |
1676 | |
1677 | iterator |
1678 | insert(const_iterator __p, initializer_list<value_type> __l) |
1679 | { |
1680 | auto __offset = __p - cbegin(); |
1681 | _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(), |
1682 | std::random_access_iterator_tag()); |
1683 | return begin() + __offset; |
1684 | } |
1685 | #endif |
1686 | |
1687 | #if __cplusplus >= 201103L |
1688 | |
1689 | |
1690 | |
1691 | |
1692 | |
1693 | |
1694 | |
1695 | |
1696 | |
1697 | |
1698 | iterator |
1699 | insert(const_iterator __position, size_type __n, const value_type& __x) |
1700 | { |
1701 | difference_type __offset = __position - cbegin(); |
1702 | _M_fill_insert(__position._M_const_cast(), __n, __x); |
1703 | return begin() + __offset; |
1704 | } |
1705 | #else |
1706 | |
1707 | |
1708 | |
1709 | |
1710 | |
1711 | |
1712 | |
1713 | |
1714 | |
1715 | void |
1716 | insert(iterator __position, size_type __n, const value_type& __x) |
1717 | { _M_fill_insert(__position, __n, __x); } |
1718 | #endif |
1719 | |
1720 | #if __cplusplus >= 201103L |
1721 | |
1722 | |
1723 | |
1724 | |
1725 | |
1726 | |
1727 | |
1728 | |
1729 | |
1730 | |
1731 | |
1732 | template<typename _InputIterator, |
1733 | typename = std::_RequireInputIter<_InputIterator>> |
1734 | iterator |
1735 | insert(const_iterator __position, _InputIterator __first, |
1736 | _InputIterator __last) |
1737 | { |
1738 | difference_type __offset = __position - cbegin(); |
1739 | _M_insert_dispatch(__position._M_const_cast(), |
1740 | __first, __last, __false_type()); |
1741 | return begin() + __offset; |
1742 | } |
1743 | #else |
1744 | |
1745 | |
1746 | |
1747 | |
1748 | |
1749 | |
1750 | |
1751 | |
1752 | |
1753 | |
1754 | template<typename _InputIterator> |
1755 | void |
1756 | insert(iterator __position, _InputIterator __first, |
1757 | _InputIterator __last) |
1758 | { |
1759 | |
1760 | typedef typename std::__is_integer<_InputIterator>::__type _Integral; |
1761 | _M_insert_dispatch(__position, __first, __last, _Integral()); |
1762 | } |
1763 | #endif |
1764 | |
1765 | |
1766 | |
1767 | |
1768 | |
1769 | |
1770 | |
1771 | |
1772 | |
1773 | |
1774 | |
1775 | |
1776 | |
1777 | |
1778 | iterator |
1779 | #if __cplusplus >= 201103L |
1780 | erase(const_iterator __position) |
1781 | #else |
1782 | erase(iterator __position) |
1783 | #endif |
1784 | { return _M_erase(__position._M_const_cast()); } |
1785 | |
1786 | |
1787 | |
1788 | |
1789 | |
1790 | |
1791 | |
1792 | |
1793 | |
1794 | |
1795 | |
1796 | |
1797 | |
1798 | |
1799 | |
1800 | |
1801 | |
1802 | iterator |
1803 | #if __cplusplus >= 201103L |
1804 | erase(const_iterator __first, const_iterator __last) |
1805 | #else |
1806 | erase(iterator __first, iterator __last) |
1807 | #endif |
1808 | { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } |
1809 | |
1810 | |
1811 | |
1812 | |
1813 | |
1814 | |
1815 | |
1816 | |
1817 | |
1818 | |
1819 | |
1820 | |
1821 | void |
1822 | swap(deque& __x) _GLIBCXX_NOEXCEPT |
1823 | { |
1824 | #if __cplusplus >= 201103L |
1825 | __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value |
1826 | || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); |
1827 | #endif |
1828 | _M_impl._M_swap_data(__x._M_impl); |
1829 | _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), |
1830 | __x._M_get_Tp_allocator()); |
1831 | } |
1832 | |
1833 | |
1834 | |
1835 | |
1836 | |
1837 | |
1838 | |
1839 | void |
1840 | clear() _GLIBCXX_NOEXCEPT |
1841 | { _M_erase_at_end(begin()); } |
1842 | |
1843 | protected: |
1844 | |
1845 | |
1846 | |
1847 | |
1848 | |
1849 | |
1850 | template<typename _Integer> |
1851 | void |
1852 | _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) |
1853 | { |
1854 | _M_initialize_map(static_cast<size_type>(__n)); |
1855 | _M_fill_initialize(__x); |
1856 | } |
1857 | |
1858 | |
1859 | template<typename _InputIterator> |
1860 | void |
1861 | _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, |
1862 | __false_type) |
1863 | { |
1864 | _M_range_initialize(__first, __last, |
1865 | std::__iterator_category(__first)); |
1866 | } |
1867 | |
1868 | |
1869 | |
1870 | |
1871 | |
1872 | |
1873 | |
1874 | |
1875 | |
1876 | |
1877 | |
1878 | |
1879 | |
1880 | template<typename _InputIterator> |
1881 | void |
1882 | _M_range_initialize(_InputIterator __first, _InputIterator __last, |
1883 | std::input_iterator_tag); |
1884 | |
1885 | |
1886 | template<typename _ForwardIterator> |
1887 | void |
1888 | _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, |
1889 | std::forward_iterator_tag); |
1890 | |
1891 | |
1892 | |
1893 | |
1894 | |
1895 | |
1896 | |
1897 | |
1898 | |
1899 | |
1900 | |
1901 | |
1902 | void |
1903 | _M_fill_initialize(const value_type& __value); |
1904 | |
1905 | #if __cplusplus >= 201103L |
1906 | |
1907 | void |
1908 | _M_default_initialize(); |
1909 | #endif |
1910 | |
1911 | |
1912 | |
1913 | |
1914 | |
1915 | |
1916 | |
1917 | |
1918 | template<typename _Integer> |
1919 | void |
1920 | _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) |
1921 | { _M_fill_assign(__n, __val); } |
1922 | |
1923 | |
1924 | template<typename _InputIterator> |
1925 | void |
1926 | _M_assign_dispatch(_InputIterator __first, _InputIterator __last, |
1927 | __false_type) |
1928 | { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } |
1929 | |
1930 | |
1931 | template<typename _InputIterator> |
1932 | void |
1933 | _M_assign_aux(_InputIterator __first, _InputIterator __last, |
1934 | std::input_iterator_tag); |
1935 | |
1936 | |
1937 | template<typename _ForwardIterator> |
1938 | void |
1939 | _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, |
1940 | std::forward_iterator_tag) |
1941 | { |
1942 | const size_type __len = std::distance(__first, __last); |
1943 | if (__len > size()) |
1944 | { |
1945 | _ForwardIterator __mid = __first; |
1946 | std::advance(__mid, size()); |
1947 | std::copy(__first, __mid, begin()); |
1948 | _M_range_insert_aux(end(), __mid, __last, |
1949 | std::__iterator_category(__first)); |
1950 | } |
1951 | else |
1952 | _M_erase_at_end(std::copy(__first, __last, begin())); |
1953 | } |
1954 | |
1955 | |
1956 | |
1957 | void |
1958 | _M_fill_assign(size_type __n, const value_type& __val) |
1959 | { |
1960 | if (__n > size()) |
1961 | { |
1962 | std::fill(begin(), end(), __val); |
1963 | _M_fill_insert(end(), __n - size(), __val); |
1964 | } |
1965 | else |
1966 | { |
1967 | _M_erase_at_end(begin() + difference_type(__n)); |
1968 | std::fill(begin(), end(), __val); |
1969 | } |
1970 | } |
1971 | |
1972 | |
1973 | |
1974 | #if __cplusplus < 201103L |
1975 | void _M_push_back_aux(const value_type&); |
1976 | |
1977 | void _M_push_front_aux(const value_type&); |
1978 | #else |
1979 | template<typename... _Args> |
1980 | void _M_push_back_aux(_Args&&... __args); |
1981 | |
1982 | template<typename... _Args> |
1983 | void _M_push_front_aux(_Args&&... __args); |
1984 | #endif |
1985 | |
1986 | void _M_pop_back_aux(); |
1987 | |
1988 | void _M_pop_front_aux(); |
1989 | |
1990 | |
1991 | |
1992 | |
1993 | |
1994 | |
1995 | |
1996 | |
1997 | |
1998 | template<typename _Integer> |
1999 | void |
2000 | _M_insert_dispatch(iterator __pos, |
2001 | _Integer __n, _Integer __x, __true_type) |
2002 | { _M_fill_insert(__pos, __n, __x); } |
2003 | |
2004 | |
2005 | template<typename _InputIterator> |
2006 | void |
2007 | _M_insert_dispatch(iterator __pos, |
2008 | _InputIterator __first, _InputIterator __last, |
2009 | __false_type) |
2010 | { |
2011 | _M_range_insert_aux(__pos, __first, __last, |
2012 | std::__iterator_category(__first)); |
2013 | } |
2014 | |
2015 | |
2016 | template<typename _InputIterator> |
2017 | void |
2018 | _M_range_insert_aux(iterator __pos, _InputIterator __first, |
2019 | _InputIterator __last, std::input_iterator_tag); |
2020 | |
2021 | |
2022 | template<typename _ForwardIterator> |
2023 | void |
2024 | _M_range_insert_aux(iterator __pos, _ForwardIterator __first, |
2025 | _ForwardIterator __last, std::forward_iterator_tag); |
2026 | |
2027 | |
2028 | |
2029 | |
2030 | void |
2031 | _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); |
2032 | |
2033 | |
2034 | #if __cplusplus < 201103L |
2035 | iterator |
2036 | _M_insert_aux(iterator __pos, const value_type& __x); |
2037 | #else |
2038 | template<typename... _Args> |
2039 | iterator |
2040 | _M_insert_aux(iterator __pos, _Args&&... __args); |
2041 | #endif |
2042 | |
2043 | |
2044 | void |
2045 | _M_insert_aux(iterator __pos, size_type __n, const value_type& __x); |
2046 | |
2047 | |
2048 | template<typename _ForwardIterator> |
2049 | void |
2050 | _M_insert_aux(iterator __pos, |
2051 | _ForwardIterator __first, _ForwardIterator __last, |
2052 | size_type __n); |
2053 | |
2054 | |
2055 | |
2056 | |
2057 | void |
2058 | _M_destroy_data_aux(iterator __first, iterator __last); |
2059 | |
2060 | |
2061 | |
2062 | template<typename _Alloc1> |
2063 | void |
2064 | _M_destroy_data(iterator __first, iterator __last, const _Alloc1&) |
2065 | { _M_destroy_data_aux(__first, __last); } |
2066 | |
2067 | void |
2068 | _M_destroy_data(iterator __first, iterator __last, |
2069 | const std::allocator<_Tp>&) |
2070 | { |
2071 | if (!__has_trivial_destructor(value_type)) |
2072 | _M_destroy_data_aux(__first, __last); |
2073 | } |
2074 | |
2075 | |
2076 | void |
2077 | _M_erase_at_begin(iterator __pos) |
2078 | { |
2079 | _M_destroy_data(begin(), __pos, _M_get_Tp_allocator()); |
2080 | _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node); |
2081 | this->_M_impl._M_start = __pos; |
2082 | } |
2083 | |
2084 | |
2085 | |
2086 | void |
2087 | _M_erase_at_end(iterator __pos) |
2088 | { |
2089 | _M_destroy_data(__pos, end(), _M_get_Tp_allocator()); |
2090 | _M_destroy_nodes(__pos._M_node + 1, |
2091 | this->_M_impl._M_finish._M_node + 1); |
2092 | this->_M_impl._M_finish = __pos; |
2093 | } |
2094 | |
2095 | iterator |
2096 | _M_erase(iterator __pos); |
2097 | |
2098 | iterator |
2099 | _M_erase(iterator __first, iterator __last); |
2100 | |
2101 | #if __cplusplus >= 201103L |
2102 | |
2103 | void |
2104 | _M_default_append(size_type __n); |
2105 | |
2106 | bool |
2107 | _M_shrink_to_fit(); |
2108 | #endif |
2109 | |
2110 | |
2111 | |
2112 | iterator |
2113 | _M_reserve_elements_at_front(size_type __n) |
2114 | { |
2115 | const size_type __vacancies = this->_M_impl._M_start._M_cur |
2116 | - this->_M_impl._M_start._M_first; |
2117 | if (__n > __vacancies) |
2118 | _M_new_elements_at_front(__n - __vacancies); |
2119 | return this->_M_impl._M_start - difference_type(__n); |
2120 | } |
2121 | |
2122 | iterator |
2123 | _M_reserve_elements_at_back(size_type __n) |
2124 | { |
2125 | const size_type __vacancies = (this->_M_impl._M_finish._M_last |
2126 | - this->_M_impl._M_finish._M_cur) - 1; |
2127 | if (__n > __vacancies) |
2128 | _M_new_elements_at_back(__n - __vacancies); |
2129 | return this->_M_impl._M_finish + difference_type(__n); |
2130 | } |
2131 | |
2132 | void |
2133 | _M_new_elements_at_front(size_type __new_elements); |
2134 | |
2135 | void |
2136 | _M_new_elements_at_back(size_type __new_elements); |
2137 | |
2138 | |
2139 | |
2140 | |
2141 | |
2142 | |
2143 | |
2144 | |
2145 | |
2146 | |
2147 | |
2148 | void |
2149 | _M_reserve_map_at_back(size_type __nodes_to_add = 1) |
2150 | { |
2151 | if (__nodes_to_add + 1 > this->_M_impl._M_map_size |
2152 | - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map)) |
2153 | _M_reallocate_map(__nodes_to_add, false); |
2154 | } |
2155 | |
2156 | void |
2157 | _M_reserve_map_at_front(size_type __nodes_to_add = 1) |
2158 | { |
2159 | if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node |
2160 | - this->_M_impl._M_map)) |
2161 | _M_reallocate_map(__nodes_to_add, true); |
2162 | } |
2163 | |
2164 | void |
2165 | _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); |
2166 | |
2167 | |
2168 | #if __cplusplus >= 201103L |
2169 | |
2170 | |
2171 | void |
2172 | _M_move_assign1(deque&& __x, true_type) noexcept |
2173 | { |
2174 | this->_M_impl._M_swap_data(__x._M_impl); |
2175 | __x.clear(); |
2176 | std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); |
2177 | } |
2178 | |
2179 | |
2180 | |
2181 | |
2182 | void |
2183 | _M_move_assign1(deque&& __x, false_type) |
2184 | { |
2185 | constexpr bool __move_storage = |
2186 | _Alloc_traits::_S_propagate_on_move_assign(); |
2187 | _M_move_assign2(std::move(__x), __bool_constant<__move_storage>()); |
2188 | } |
2189 | |
2190 | |
2191 | |
2192 | template<typename... _Args> |
2193 | void |
2194 | _M_replace_map(_Args&&... __args) |
2195 | { |
2196 | |
2197 | deque __newobj(std::forward<_Args>(__args)...); |
2198 | |
2199 | clear(); |
2200 | _M_deallocate_node(*begin()._M_node); |
2201 | _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); |
2202 | this->_M_impl._M_map = nullptr; |
2203 | this->_M_impl._M_map_size = 0; |
2204 | |
2205 | this->_M_impl._M_swap_data(__newobj._M_impl); |
2206 | } |
2207 | |
2208 | |
2209 | void |
2210 | _M_move_assign2(deque&& __x, true_type) |
2211 | { |
2212 | |
2213 | auto __alloc = __x._M_get_Tp_allocator(); |
2214 | |
2215 | |
2216 | _M_replace_map(std::move(__x)); |
2217 | |
2218 | _M_get_Tp_allocator() = std::move(__alloc); |
2219 | } |
2220 | |
2221 | |
2222 | |
2223 | void |
2224 | _M_move_assign2(deque&& __x, false_type) |
2225 | { |
2226 | if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) |
2227 | { |
2228 | |
2229 | |
2230 | _M_replace_map(std::move(__x), __x.get_allocator()); |
2231 | } |
2232 | else |
2233 | { |
2234 | |
2235 | |
2236 | _M_assign_aux(std::__make_move_if_noexcept_iterator(__x.begin()), |
2237 | std::__make_move_if_noexcept_iterator(__x.end()), |
2238 | std::random_access_iterator_tag()); |
2239 | __x.clear(); |
2240 | } |
2241 | } |
2242 | #endif |
2243 | }; |
2244 | |
2245 | |
2246 | |
2247 | |
2248 | |
2249 | |
2250 | |
2251 | |
2252 | |
2253 | |
2254 | |
2255 | |
2256 | template<typename _Tp, typename _Alloc> |
2257 | inline bool |
2258 | operator==(const deque<_Tp, _Alloc>& __x, |
2259 | const deque<_Tp, _Alloc>& __y) |
2260 | { return __x.size() == __y.size() |
2261 | && std::equal(__x.begin(), __x.end(), __y.begin()); } |
2262 | |
2263 | |
2264 | |
2265 | |
2266 | |
2267 | |
2268 | |
2269 | |
2270 | |
2271 | |
2272 | |
2273 | |
2274 | template<typename _Tp, typename _Alloc> |
2275 | inline bool |
2276 | operator<(const deque<_Tp, _Alloc>& __x, |
2277 | const deque<_Tp, _Alloc>& __y) |
2278 | { return std::lexicographical_compare(__x.begin(), __x.end(), |
2279 | __y.begin(), __y.end()); } |
2280 | |
2281 | |
2282 | template<typename _Tp, typename _Alloc> |
2283 | inline bool |
2284 | operator!=(const deque<_Tp, _Alloc>& __x, |
2285 | const deque<_Tp, _Alloc>& __y) |
2286 | { return !(__x == __y); } |
2287 | |
2288 | |
2289 | template<typename _Tp, typename _Alloc> |
2290 | inline bool |
2291 | operator>(const deque<_Tp, _Alloc>& __x, |
2292 | const deque<_Tp, _Alloc>& __y) |
2293 | { return __y < __x; } |
2294 | |
2295 | |
2296 | template<typename _Tp, typename _Alloc> |
2297 | inline bool |
2298 | operator<=(const deque<_Tp, _Alloc>& __x, |
2299 | const deque<_Tp, _Alloc>& __y) |
2300 | { return !(__y < __x); } |
2301 | |
2302 | |
2303 | template<typename _Tp, typename _Alloc> |
2304 | inline bool |
2305 | operator>=(const deque<_Tp, _Alloc>& __x, |
2306 | const deque<_Tp, _Alloc>& __y) |
2307 | { return !(__x < __y); } |
2308 | |
2309 | |
2310 | template<typename _Tp, typename _Alloc> |
2311 | inline void |
2312 | swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) |
2313 | _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) |
2314 | { __x.swap(__y); } |
2315 | |
2316 | #undef _GLIBCXX_DEQUE_BUF_SIZE |
2317 | |
2318 | _GLIBCXX_END_NAMESPACE_CONTAINER |
2319 | } |
2320 | |
2321 | #endif |
2322 | |