]>
Commit | Line | Data |
---|---|---|
1218d701 SR |
1 | // Profiling deque implementation -*- C++ -*- |
2 | ||
a5544970 | 3 | // Copyright (C) 2009-2019 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 | 34 | namespace std _GLIBCXX_VISIBILITY(default) |
1218d701 SR |
35 | { |
36 | namespace __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: | |
f3de79d4 FD |
46 | typedef typename _Base::size_type size_type; |
47 | typedef typename _Base::value_type value_type; | |
1218d701 SR |
48 | |
49 | // 23.2.1.1 construct/copy/destroy: | |
c3cdd71f | 50 | |
f3de79d4 | 51 | #if __cplusplus < 201103L |
c3cdd71f JW |
52 | deque() |
53 | : _Base() { } | |
f3de79d4 FD |
54 | deque(const deque& __x) |
55 | : _Base(__x) { } | |
56 | ||
57 | ~deque() { } | |
58 | #else | |
59 | deque() = default; | |
60 | deque(const deque&) = default; | |
61 | deque(deque&&) = default; | |
62 | ||
fd18c76a JW |
63 | deque(const deque& __d, const _Allocator& __a) |
64 | : _Base(__d, __a) { } | |
65 | ||
66 | deque(deque&& __d, const _Allocator& __a) | |
67 | : _Base(std::move(__d), __a) { } | |
68 | ||
f3de79d4 FD |
69 | ~deque() = default; |
70 | ||
71 | deque(initializer_list<value_type> __l, | |
72 | const _Allocator& __a = _Allocator()) | |
73 | : _Base(__l, __a) { } | |
74 | #endif | |
c3cdd71f | 75 | |
dc2cf706 | 76 | explicit |
c3cdd71f | 77 | deque(const _Allocator& __a) |
1218d701 SR |
78 | : _Base(__a) { } |
79 | ||
734f5023 | 80 | #if __cplusplus >= 201103L |
dc2cf706 | 81 | explicit |
fd18c76a JW |
82 | deque(size_type __n, const _Allocator& __a = _Allocator()) |
83 | : _Base(__n, __a) { } | |
dc2cf706 PC |
84 | |
85 | deque(size_type __n, const _Tp& __value, | |
86 | const _Allocator& __a = _Allocator()) | |
1218d701 | 87 | : _Base(__n, __value, __a) { } |
dc2cf706 PC |
88 | #else |
89 | explicit | |
90 | deque(size_type __n, const _Tp& __value = _Tp(), | |
91 | const _Allocator& __a = _Allocator()) | |
92 | : _Base(__n, __value, __a) { } | |
93 | #endif | |
1218d701 | 94 | |
734f5023 | 95 | #if __cplusplus >= 201103L |
3c7d8b03 JW |
96 | template<typename _InputIterator, |
97 | typename = std::_RequireInputIter<_InputIterator>> | |
98 | #else | |
99 | template<typename _InputIterator> | |
100 | #endif | |
f3de79d4 | 101 | deque(_InputIterator __first, _InputIterator __last, |
1218d701 SR |
102 | const _Allocator& __a = _Allocator()) |
103 | : _Base(__first, __last, __a) | |
f3de79d4 | 104 | { } |
1218d701 SR |
105 | |
106 | deque(const _Base& __x) | |
107 | : _Base(__x) { } | |
108 | ||
f3de79d4 | 109 | #if __cplusplus < 201103L |
1218d701 SR |
110 | deque& |
111 | operator=(const deque& __x) | |
112 | { | |
f3de79d4 | 113 | _M_base() = __x; |
1218d701 SR |
114 | return *this; |
115 | } | |
f3de79d4 FD |
116 | #else |
117 | deque& | |
118 | operator=(const deque&) = default; | |
1218d701 | 119 | |
1218d701 | 120 | deque& |
f3de79d4 | 121 | operator=(deque&&) = default; |
1218d701 SR |
122 | |
123 | deque& | |
124 | operator=(initializer_list<value_type> __l) | |
125 | { | |
f3de79d4 | 126 | _M_base() = __l; |
1218d701 SR |
127 | return *this; |
128 | } | |
129 | #endif | |
130 | ||
1218d701 | 131 | void |
f3de79d4 | 132 | swap(deque& __x) |
c5d9ec56 | 133 | _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) |
f3de79d4 | 134 | { _Base::swap(__x); } |
1218d701 SR |
135 | |
136 | _Base& | |
f3de79d4 | 137 | _M_base() _GLIBCXX_NOEXCEPT { return *this; } |
1218d701 SR |
138 | |
139 | const _Base& | |
f3de79d4 | 140 | _M_base() const _GLIBCXX_NOEXCEPT { return *this; } |
1218d701 SR |
141 | }; |
142 | ||
143 | template<typename _Tp, typename _Alloc> | |
144 | inline bool | |
145 | operator==(const deque<_Tp, _Alloc>& __lhs, | |
146 | const deque<_Tp, _Alloc>& __rhs) | |
147 | { return __lhs._M_base() == __rhs._M_base(); } | |
148 | ||
149 | template<typename _Tp, typename _Alloc> | |
150 | inline bool | |
151 | operator!=(const deque<_Tp, _Alloc>& __lhs, | |
152 | const deque<_Tp, _Alloc>& __rhs) | |
153 | { return __lhs._M_base() != __rhs._M_base(); } | |
154 | ||
155 | template<typename _Tp, typename _Alloc> | |
156 | inline bool | |
157 | operator<(const deque<_Tp, _Alloc>& __lhs, | |
158 | const deque<_Tp, _Alloc>& __rhs) | |
159 | { return __lhs._M_base() < __rhs._M_base(); } | |
160 | ||
161 | template<typename _Tp, typename _Alloc> | |
162 | inline bool | |
163 | operator<=(const deque<_Tp, _Alloc>& __lhs, | |
164 | const deque<_Tp, _Alloc>& __rhs) | |
165 | { return __lhs._M_base() <= __rhs._M_base(); } | |
166 | ||
167 | template<typename _Tp, typename _Alloc> | |
168 | inline bool | |
169 | operator>=(const deque<_Tp, _Alloc>& __lhs, | |
170 | const deque<_Tp, _Alloc>& __rhs) | |
171 | { return __lhs._M_base() >= __rhs._M_base(); } | |
172 | ||
173 | template<typename _Tp, typename _Alloc> | |
174 | inline bool | |
175 | operator>(const deque<_Tp, _Alloc>& __lhs, | |
176 | const deque<_Tp, _Alloc>& __rhs) | |
177 | { return __lhs._M_base() > __rhs._M_base(); } | |
178 | ||
179 | template<typename _Tp, typename _Alloc> | |
180 | inline void | |
181 | swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) | |
c5d9ec56 | 182 | _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) |
1218d701 SR |
183 | { __lhs.swap(__rhs); } |
184 | ||
185 | } // namespace __profile | |
186 | } // namespace std | |
187 | ||
188 | #endif |