]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/profile/deque
re PR libstdc++/58764 ([lwg/2193] error: converting to ‘const std::vector<std::basic_...
[thirdparty/gcc.git] / libstdc++-v3 / include / profile / deque
CommitLineData
1218d701
SR
1// Profiling deque implementation -*- C++ -*-
2
aa118a03 3// Copyright (C) 2009-2014 Free Software Foundation, Inc.
1218d701
SR
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
8// Free Software Foundation; either version 3, or (at your option)
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
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/>.
24
25/** @file profile/deque
26 * This file is a GNU profile extension to the Standard C++ Library.
27 */
28
29#ifndef _GLIBCXX_PROFILE_DEQUE
30#define _GLIBCXX_PROFILE_DEQUE 1
31
32#include <deque>
33
12ffa228 34namespace std _GLIBCXX_VISIBILITY(default)
1218d701
SR
35{
36namespace __profile
37{
9ee6a740 38 /// Class std::deque wrapper with performance instrumentation.
1218d701
SR
39 template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
40 class deque
12ffa228 41 : public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
1218d701 42 {
12ffa228 43 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
1218d701
SR
44
45 public:
46 typedef typename _Base::reference reference;
47 typedef typename _Base::const_reference const_reference;
48
49 typedef typename _Base::iterator iterator;
50 typedef typename _Base::const_iterator const_iterator;
51 typedef typename _Base::reverse_iterator reverse_iterator;
52 typedef typename _Base::const_reverse_iterator const_reverse_iterator;
53
54 typedef typename _Base::size_type size_type;
55 typedef typename _Base::difference_type difference_type;
56
57 typedef _Tp value_type;
58 typedef _Allocator allocator_type;
59 typedef typename _Base::pointer pointer;
60 typedef typename _Base::const_pointer const_pointer;
61
62 // 23.2.1.1 construct/copy/destroy:
c3cdd71f
JW
63
64 deque()
65 : _Base() { }
66
dc2cf706 67 explicit
c3cdd71f 68 deque(const _Allocator& __a)
1218d701
SR
69 : _Base(__a) { }
70
734f5023 71#if __cplusplus >= 201103L
dc2cf706
PC
72 explicit
73 deque(size_type __n)
74 : _Base(__n) { }
75
76 deque(size_type __n, const _Tp& __value,
77 const _Allocator& __a = _Allocator())
1218d701 78 : _Base(__n, __value, __a) { }
dc2cf706
PC
79#else
80 explicit
81 deque(size_type __n, const _Tp& __value = _Tp(),
82 const _Allocator& __a = _Allocator())
83 : _Base(__n, __value, __a) { }
84#endif
1218d701 85
734f5023 86#if __cplusplus >= 201103L
3c7d8b03
JW
87 template<typename _InputIterator,
88 typename = std::_RequireInputIter<_InputIterator>>
89#else
90 template<typename _InputIterator>
91#endif
1218d701
SR
92 deque(_InputIterator __first, _InputIterator __last,
93 const _Allocator& __a = _Allocator())
94 : _Base(__first, __last, __a)
95 { }
96
97 deque(const deque& __x)
98 : _Base(__x) { }
99
100 deque(const _Base& __x)
101 : _Base(__x) { }
102
734f5023 103#if __cplusplus >= 201103L
1218d701 104 deque(deque&& __x)
5f1fd346 105 : _Base(std::move(__x))
1218d701
SR
106 { }
107
108 deque(initializer_list<value_type> __l,
109 const allocator_type& __a = allocator_type())
110 : _Base(__l, __a) { }
111#endif
112
6f59ea25 113 ~deque() _GLIBCXX_NOEXCEPT { }
1218d701
SR
114
115 deque&
116 operator=(const deque& __x)
117 {
118 *static_cast<_Base*>(this) = __x;
119 return *this;
120 }
121
734f5023 122#if __cplusplus >= 201103L
1218d701 123 deque&
d15ac9d9 124 operator=(deque&& __x) noexcept
1218d701 125 {
0462fd5e
PC
126 // NB: DR 1204.
127 // NB: DR 675.
128 this->clear();
129 this->swap(__x);
1218d701
SR
130 return *this;
131 }
132
133 deque&
134 operator=(initializer_list<value_type> __l)
135 {
136 *static_cast<_Base*>(this) = __l;
137 return *this;
138 }
139#endif
140
734f5023 141#if __cplusplus >= 201103L
3c7d8b03
JW
142 template<typename _InputIterator,
143 typename = std::_RequireInputIter<_InputIterator>>
144#else
145 template<typename _InputIterator>
146#endif
1218d701
SR
147 void
148 assign(_InputIterator __first, _InputIterator __last)
149 {
150 _Base::assign(__first, __last);
151 }
152
153 void
154 assign(size_type __n, const _Tp& __t)
155 {
156 _Base::assign(__n, __t);
157 }
158
734f5023 159#if __cplusplus >= 201103L
1218d701
SR
160 void
161 assign(initializer_list<value_type> __l)
162 {
163 _Base::assign(__l);
164 }
165#endif
166
167 using _Base::get_allocator;
168
169 // iterators:
170 iterator
d3677132 171 begin() _GLIBCXX_NOEXCEPT
1218d701
SR
172 { return iterator(_Base::begin()); }
173
174 const_iterator
d3677132 175 begin() const _GLIBCXX_NOEXCEPT
1218d701
SR
176 { return const_iterator(_Base::begin()); }
177
178 iterator
d3677132 179 end() _GLIBCXX_NOEXCEPT
1218d701
SR
180 { return iterator(_Base::end()); }
181
182 const_iterator
d3677132 183 end() const _GLIBCXX_NOEXCEPT
1218d701
SR
184 { return const_iterator(_Base::end()); }
185
186 reverse_iterator
d3677132 187 rbegin() _GLIBCXX_NOEXCEPT
1218d701
SR
188 { return reverse_iterator(end()); }
189
190 const_reverse_iterator
d3677132 191 rbegin() const _GLIBCXX_NOEXCEPT
1218d701
SR
192 { return const_reverse_iterator(end()); }
193
194 reverse_iterator
d3677132 195 rend() _GLIBCXX_NOEXCEPT
1218d701
SR
196 { return reverse_iterator(begin()); }
197
198 const_reverse_iterator
d3677132 199 rend() const _GLIBCXX_NOEXCEPT
1218d701
SR
200 { return const_reverse_iterator(begin()); }
201
734f5023 202#if __cplusplus >= 201103L
1218d701 203 const_iterator
d3677132 204 cbegin() const noexcept
1218d701
SR
205 { return const_iterator(_Base::begin()); }
206
207 const_iterator
d3677132 208 cend() const noexcept
1218d701
SR
209 { return const_iterator(_Base::end()); }
210
211 const_reverse_iterator
d3677132 212 crbegin() const noexcept
1218d701
SR
213 { return const_reverse_iterator(end()); }
214
215 const_reverse_iterator
d3677132 216 crend() const noexcept
1218d701
SR
217 { return const_reverse_iterator(begin()); }
218#endif
219
220 // 23.2.1.2 capacity:
221 using _Base::size;
222 using _Base::max_size;
223
734f5023 224#if __cplusplus >= 201103L
dc2cf706
PC
225 void
226 resize(size_type __sz)
227 {
228 _Base::resize(__sz);
229 }
230
231 void
232 resize(size_type __sz, const _Tp& __c)
233 {
234 _Base::resize(__sz, __c);
235 }
236#else
1218d701
SR
237 void
238 resize(size_type __sz, _Tp __c = _Tp())
239 {
240 _Base::resize(__sz, __c);
241 }
dc2cf706 242#endif
1218d701 243
734f5023 244#if __cplusplus >= 201103L
79667f82
PC
245 using _Base::shrink_to_fit;
246#endif
247
1218d701
SR
248 using _Base::empty;
249
250 // element access:
251 reference
d15ac9d9 252 operator[](size_type __n) _GLIBCXX_NOEXCEPT
1218d701
SR
253 {
254 return _M_base()[__n];
255 }
256
257 const_reference
d15ac9d9 258 operator[](size_type __n) const _GLIBCXX_NOEXCEPT
1218d701
SR
259 {
260 return _M_base()[__n];
261 }
262
263 using _Base::at;
264
265 reference
d15ac9d9 266 front() _GLIBCXX_NOEXCEPT
1218d701
SR
267 {
268 return _Base::front();
269 }
270
271 const_reference
d15ac9d9 272 front() const _GLIBCXX_NOEXCEPT
1218d701
SR
273 {
274 return _Base::front();
275 }
276
277 reference
d15ac9d9 278 back() _GLIBCXX_NOEXCEPT
1218d701
SR
279 {
280 return _Base::back();
281 }
282
283 const_reference
d15ac9d9 284 back() const _GLIBCXX_NOEXCEPT
1218d701
SR
285 {
286 return _Base::back();
287 }
288
289 // 23.2.1.3 modifiers:
290 void
291 push_front(const _Tp& __x)
292 {
293 _Base::push_front(__x);
294 }
295
296 void
297 push_back(const _Tp& __x)
298 {
299 _Base::push_back(__x);
300 }
301
734f5023 302#if __cplusplus >= 201103L
1218d701
SR
303 void
304 push_front(_Tp&& __x)
305 { emplace_front(std::move(__x)); }
306
307 void
308 push_back(_Tp&& __x)
309 { emplace_back(std::move(__x)); }
310
311 template<typename... _Args>
312 void
313 emplace_front(_Args&&... __args)
314 {
315 _Base::emplace_front(std::forward<_Args>(__args)...);
316 }
317
318 template<typename... _Args>
319 void
320 emplace_back(_Args&&... __args)
321 {
322 _Base::emplace_back(std::forward<_Args>(__args)...);
323 }
324
325 template<typename... _Args>
326 iterator
7b61c5a9 327 emplace(const_iterator __position, _Args&&... __args)
1218d701
SR
328 {
329 typename _Base::iterator __res = _Base::emplace(__position,
330 std::forward<_Args>(__args)...);
331 return iterator(__res);
332 }
333#endif
334
335 iterator
7b61c5a9
PC
336#if __cplusplus >= 201103L
337 insert(const_iterator __position, const _Tp& __x)
338#else
1218d701 339 insert(iterator __position, const _Tp& __x)
7b61c5a9 340#endif
1218d701
SR
341 {
342 typename _Base::iterator __res = _Base::insert(__position, __x);
343 return iterator(__res);
344 }
345
734f5023 346#if __cplusplus >= 201103L
1218d701 347 iterator
7b61c5a9 348 insert(const_iterator __position, _Tp&& __x)
1218d701
SR
349 { return emplace(__position, std::move(__x)); }
350
06eed9f5
PC
351 iterator
352 insert(const_iterator __p, initializer_list<value_type> __l)
353 { return _Base::insert(__p, __l); }
1218d701
SR
354#endif
355
06eed9f5
PC
356#if __cplusplus >= 201103L
357 iterator
358 insert(const_iterator __position, size_type __n, const _Tp& __x)
359 { return _Base::insert(__position, __n, __x); }
360#else
1218d701
SR
361 void
362 insert(iterator __position, size_type __n, const _Tp& __x)
06eed9f5
PC
363 { _Base::insert(__position, __n, __x); }
364#endif
1218d701 365
734f5023 366#if __cplusplus >= 201103L
3c7d8b03
JW
367 template<typename _InputIterator,
368 typename = std::_RequireInputIter<_InputIterator>>
06eed9f5
PC
369 iterator
370 insert(const_iterator __position,
371 _InputIterator __first, _InputIterator __last)
372 { return _Base::insert(__position, __first, __last); }
3c7d8b03
JW
373#else
374 template<typename _InputIterator>
1218d701
SR
375 void
376 insert(iterator __position,
377 _InputIterator __first, _InputIterator __last)
06eed9f5
PC
378 { _Base::insert(__position, __first, __last); }
379#endif
1218d701
SR
380
381 void
d15ac9d9 382 pop_front() _GLIBCXX_NOEXCEPT
1218d701
SR
383 {
384 _Base::pop_front();
385 }
386
387 void
d15ac9d9 388 pop_back() _GLIBCXX_NOEXCEPT
1218d701
SR
389 {
390 _Base::pop_back();
391 }
392
393 iterator
94938aec
PC
394#if __cplusplus >= 201103L
395 erase(const_iterator __position)
396#else
397 erase(iterator __position)
398#endif
1218d701 399 {
94938aec 400 return _Base::erase(__position);
1218d701
SR
401 }
402
403 iterator
94938aec
PC
404#if __cplusplus >= 201103L
405 erase(const_iterator __first, const_iterator __last)
406#else
1218d701 407 erase(iterator __first, iterator __last)
94938aec 408#endif
1218d701
SR
409 {
410 // _GLIBCXX_RESOLVE_LIB_DEFECTS
411 // 151. can't currently clear() empty container
94938aec 412 return _Base::erase(__first, __last);
1218d701
SR
413 }
414
415 void
d15ac9d9 416 swap(deque& __x) _GLIBCXX_NOEXCEPT
1218d701
SR
417 {
418 _Base::swap(__x);
419 }
420
421 void
d3677132 422 clear() _GLIBCXX_NOEXCEPT
1218d701
SR
423 {
424 _Base::clear();
425 }
426
427 _Base&
d3677132 428 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
1218d701
SR
429
430 const _Base&
d3677132 431 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
1218d701
SR
432 };
433
434 template<typename _Tp, typename _Alloc>
435 inline bool
436 operator==(const deque<_Tp, _Alloc>& __lhs,
437 const deque<_Tp, _Alloc>& __rhs)
438 { return __lhs._M_base() == __rhs._M_base(); }
439
440 template<typename _Tp, typename _Alloc>
441 inline bool
442 operator!=(const deque<_Tp, _Alloc>& __lhs,
443 const deque<_Tp, _Alloc>& __rhs)
444 { return __lhs._M_base() != __rhs._M_base(); }
445
446 template<typename _Tp, typename _Alloc>
447 inline bool
448 operator<(const deque<_Tp, _Alloc>& __lhs,
449 const deque<_Tp, _Alloc>& __rhs)
450 { return __lhs._M_base() < __rhs._M_base(); }
451
452 template<typename _Tp, typename _Alloc>
453 inline bool
454 operator<=(const deque<_Tp, _Alloc>& __lhs,
455 const deque<_Tp, _Alloc>& __rhs)
456 { return __lhs._M_base() <= __rhs._M_base(); }
457
458 template<typename _Tp, typename _Alloc>
459 inline bool
460 operator>=(const deque<_Tp, _Alloc>& __lhs,
461 const deque<_Tp, _Alloc>& __rhs)
462 { return __lhs._M_base() >= __rhs._M_base(); }
463
464 template<typename _Tp, typename _Alloc>
465 inline bool
466 operator>(const deque<_Tp, _Alloc>& __lhs,
467 const deque<_Tp, _Alloc>& __rhs)
468 { return __lhs._M_base() > __rhs._M_base(); }
469
470 template<typename _Tp, typename _Alloc>
471 inline void
472 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
473 { __lhs.swap(__rhs); }
474
475} // namespace __profile
476} // namespace std
477
478#endif