]>
Commit | Line | Data |
---|---|---|
1218d701 SR |
1 | // Profiling vector implementation -*- C++ -*- |
2 | ||
cbe34bb5 | 3 | // Copyright (C) 2009-2017 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 | |
4bee90f7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
1218d701 | 9 | // any later version. |
4bee90f7 | 10 | // |
1218d701 SR |
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. | |
1889b253 PC |
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 | ||
1218d701 | 20 | // You should have received a copy of the GNU General Public License along |
4bee90f7 PC |
21 | // with this library; see the file COPYING3. If not see |
22 | // <http://www.gnu.org/licenses/>. | |
1218d701 SR |
23 | |
24 | /** @file profile/vector | |
25 | * This file is a GNU profile extension to the Standard C++ Library. | |
26 | */ | |
27 | ||
28 | #ifndef _GLIBCXX_PROFILE_VECTOR | |
29 | #define _GLIBCXX_PROFILE_VECTOR 1 | |
30 | ||
31 | #include <vector> | |
32 | #include <utility> | |
33 | #include <profile/base.h> | |
a1360f57 | 34 | #include <profile/iterator_tracker.h> |
1218d701 | 35 | |
12ffa228 | 36 | namespace std _GLIBCXX_VISIBILITY(default) |
1218d701 SR |
37 | { |
38 | namespace __profile | |
39 | { | |
f3de79d4 FD |
40 | template<typename _Vector> |
41 | class _Vector_profile_pre | |
1218d701 | 42 | { |
f3de79d4 FD |
43 | _Vector& |
44 | _M_conjure() | |
45 | { return *static_cast<_Vector*>(this); } | |
46 | ||
47 | public: | |
48 | #if __cplusplus >= 201103L | |
49 | _Vector_profile_pre() = default; | |
50 | _Vector_profile_pre(const _Vector_profile_pre&) = default; | |
51 | _Vector_profile_pre(_Vector_profile_pre&&) = default; | |
52 | ||
53 | _Vector_profile_pre& | |
b12db708 FD |
54 | operator=(const _Vector_profile_pre&) |
55 | { _M_conjure()._M_profile_destruct(); } | |
1218d701 | 56 | |
f3de79d4 FD |
57 | _Vector_profile_pre& |
58 | operator=(_Vector_profile_pre&&) noexcept | |
b12db708 | 59 | { _M_conjure()._M_profile_destruct(); } |
f3de79d4 | 60 | #endif |
f3de79d4 FD |
61 | }; |
62 | ||
63 | template<typename _Vector> | |
64 | class _Vector_profile_post | |
65 | { | |
66 | _Vector& | |
67 | _M_conjure() | |
68 | { return *static_cast<_Vector*>(this); } | |
69 | ||
70 | protected: | |
b12db708 FD |
71 | __gnu_profile::__container_size_info* _M_size_info; |
72 | __gnu_profile::__vector2list_info* _M_vect2list_info; | |
73 | ||
f3de79d4 | 74 | _Vector_profile_post() _GLIBCXX_NOEXCEPT |
b12db708 | 75 | { _M_profile_construct(); } |
06eed9f5 | 76 | |
734f5023 | 77 | #if __cplusplus >= 201103L |
f3de79d4 FD |
78 | _Vector_profile_post(const _Vector_profile_post&) noexcept |
79 | : _Vector_profile_post() { } | |
b12db708 FD |
80 | _Vector_profile_post(_Vector_profile_post&& __other) noexcept |
81 | : _Vector_profile_post() | |
82 | { _M_swap(__other); } | |
f3de79d4 FD |
83 | |
84 | _Vector_profile_post& | |
b12db708 FD |
85 | operator=(const _Vector_profile_post&) noexcept |
86 | { _M_profile_construct(); } | |
87 | ||
f3de79d4 | 88 | _Vector_profile_post& |
b12db708 FD |
89 | operator=(_Vector_profile_post&& __other) noexcept |
90 | { | |
91 | _M_swap(__other); | |
92 | __other._M_profile_construct(); | |
93 | } | |
42500675 JW |
94 | #endif |
95 | ||
f3de79d4 FD |
96 | ~_Vector_profile_post() |
97 | { _M_conjure()._M_profile_destruct(); } | |
b12db708 FD |
98 | |
99 | public: | |
100 | void | |
101 | _M_profile_construct() _GLIBCXX_NOEXCEPT | |
102 | { | |
103 | _M_size_info = | |
104 | __profcxx_vector_size_construct(_M_conjure().capacity()); | |
105 | _M_vect2list_info = __profcxx_vector2list_construct(); | |
106 | } | |
107 | ||
108 | void | |
109 | _M_profile_destruct() _GLIBCXX_NOEXCEPT | |
110 | { | |
111 | __profcxx_vector2list_destruct(_M_vect2list_info); | |
112 | _M_vect2list_info = 0; | |
113 | __profcxx_vector_size_destruct(_M_size_info, | |
114 | _M_conjure().capacity(), | |
115 | _M_conjure().size()); | |
116 | _M_size_info = 0; | |
117 | } | |
118 | ||
119 | void | |
120 | _M_swap(_Vector_profile_post& __other) _GLIBCXX_NOEXCEPT | |
121 | { | |
122 | std::swap(_M_size_info, __other._M_size_info); | |
123 | std::swap(_M_vect2list_info, __other._M_vect2list_info); | |
124 | } | |
f3de79d4 FD |
125 | }; |
126 | ||
127 | template<typename _Tp, | |
128 | typename _Allocator = std::allocator<_Tp> > | |
129 | class vector | |
130 | : public _Vector_profile_pre<vector<_Tp, _Allocator> >, | |
131 | public _GLIBCXX_STD_C::vector<_Tp, _Allocator>, | |
132 | public _Vector_profile_post<vector<_Tp, _Allocator> > | |
133 | { | |
134 | typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base; | |
135 | ||
136 | typedef typename _Base::iterator _Base_iterator; | |
137 | typedef typename _Base::const_iterator _Base_const_iterator; | |
138 | ||
1218d701 | 139 | public: |
f3de79d4 FD |
140 | typedef typename _Base::reference reference; |
141 | typedef typename _Base::const_reference const_reference; | |
1218d701 | 142 | |
06eed9f5 | 143 | typedef __iterator_tracker<_Base_iterator, vector> |
f3de79d4 | 144 | iterator; |
06eed9f5 | 145 | typedef __iterator_tracker<_Base_const_iterator, vector> |
f3de79d4 FD |
146 | const_iterator; |
147 | ||
148 | typedef typename _Base::size_type size_type; | |
149 | typedef typename _Base::difference_type difference_type; | |
150 | ||
151 | typedef _Tp value_type; | |
152 | typedef _Allocator allocator_type; | |
153 | typedef typename _Base::pointer pointer; | |
154 | typedef typename _Base::const_pointer const_pointer; | |
155 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
156 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
157 | ||
1218d701 | 158 | _Base& |
f3de79d4 | 159 | _M_base() _GLIBCXX_NOEXCEPT { return *this; } |
1218d701 SR |
160 | |
161 | const _Base& | |
f3de79d4 | 162 | _M_base() const _GLIBCXX_NOEXCEPT { return *this; } |
1218d701 SR |
163 | |
164 | // 23.2.4.1 construct/copy/destroy: | |
c3cdd71f | 165 | |
f3de79d4 FD |
166 | #if __cplusplus < 201103L |
167 | vector() | |
168 | { } | |
169 | ||
170 | vector(const vector& __x) | |
171 | : _Base(__x) { } | |
172 | #else | |
173 | vector() = default; | |
174 | vector(const vector&) = default; | |
175 | vector(vector&&) = default; | |
176 | #endif | |
c3cdd71f | 177 | |
dc2cf706 | 178 | explicit |
c3cdd71f | 179 | vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT |
f3de79d4 | 180 | : _Base(__a) { } |
1218d701 | 181 | |
734f5023 | 182 | #if __cplusplus >= 201103L |
dc2cf706 | 183 | explicit |
d720a22b | 184 | vector(size_type __n, const _Allocator& __a = _Allocator()) |
f3de79d4 | 185 | : _Base(__n, __a) { } |
dc2cf706 PC |
186 | |
187 | vector(size_type __n, const _Tp& __value, | |
188 | const _Allocator& __a = _Allocator()) | |
f3de79d4 | 189 | : _Base(__n, __value, __a) { } |
dc2cf706 PC |
190 | #else |
191 | explicit | |
192 | vector(size_type __n, const _Tp& __value = _Tp(), | |
193 | const _Allocator& __a = _Allocator()) | |
f3de79d4 | 194 | : _Base(__n, __value, __a) { } |
dc2cf706 | 195 | #endif |
1218d701 | 196 | |
734f5023 | 197 | #if __cplusplus >= 201103L |
3c7d8b03 JW |
198 | template<typename _InputIterator, |
199 | typename = std::_RequireInputIter<_InputIterator>> | |
200 | #else | |
201 | template<typename _InputIterator> | |
202 | #endif | |
f3de79d4 | 203 | vector(_InputIterator __first, _InputIterator __last, |
1218d701 | 204 | const _Allocator& __a = _Allocator()) |
f3de79d4 | 205 | : _Base(__first, __last, __a) { } |
1218d701 | 206 | |
f3de79d4 | 207 | /// Construction from a normal-mode vector |
1218d701 | 208 | vector(const _Base& __x) |
f3de79d4 | 209 | : _Base(__x) { } |
1218d701 | 210 | |
734f5023 | 211 | #if __cplusplus >= 201103L |
42500675 | 212 | vector(const _Base& __x, const _Allocator& __a) |
f3de79d4 | 213 | : _Base(__x, __a) { } |
42500675 | 214 | |
757b1644 | 215 | vector(vector&& __x, const _Allocator& __a) |
f3de79d4 | 216 | : _Base(std::move(__x), __a) { } |
42500675 | 217 | |
1218d701 SR |
218 | vector(initializer_list<value_type> __l, |
219 | const allocator_type& __a = allocator_type()) | |
220 | : _Base(__l, __a) { } | |
221 | #endif | |
222 | ||
f3de79d4 | 223 | #if __cplusplus < 201103L |
1218d701 SR |
224 | vector& |
225 | operator=(const vector& __x) | |
226 | { | |
b12db708 | 227 | this->_M_profile_destruct(); |
f3de79d4 | 228 | _M_base() = __x; |
b12db708 | 229 | this->_M_profile_construct(); |
f3de79d4 | 230 | return *this; |
1218d701 | 231 | } |
f3de79d4 FD |
232 | #else |
233 | vector& | |
234 | operator=(const vector&) = default; | |
1218d701 | 235 | |
1218d701 | 236 | vector& |
f3de79d4 | 237 | operator=(vector&&) = default; |
1218d701 SR |
238 | |
239 | vector& | |
240 | operator=(initializer_list<value_type> __l) | |
241 | { | |
b12db708 | 242 | this->_M_profile_destruct(); |
f3de79d4 | 243 | _M_base() = __l; |
b12db708 | 244 | this->_M_profile_construct(); |
1218d701 SR |
245 | return *this; |
246 | } | |
247 | #endif | |
248 | ||
a1360f57 SR |
249 | // iterators: |
250 | iterator | |
d3677132 | 251 | begin() _GLIBCXX_NOEXCEPT |
a1360f57 SR |
252 | { return iterator(_Base::begin(), this); } |
253 | ||
254 | const_iterator | |
d3677132 | 255 | begin() const _GLIBCXX_NOEXCEPT |
a1360f57 SR |
256 | { return const_iterator(_Base::begin(), this); } |
257 | ||
258 | iterator | |
d3677132 | 259 | end() _GLIBCXX_NOEXCEPT |
a1360f57 SR |
260 | { return iterator(_Base::end(), this); } |
261 | ||
262 | const_iterator | |
d3677132 | 263 | end() const _GLIBCXX_NOEXCEPT |
a1360f57 SR |
264 | { return const_iterator(_Base::end(), this); } |
265 | ||
266 | reverse_iterator | |
d3677132 | 267 | rbegin() _GLIBCXX_NOEXCEPT |
a1360f57 SR |
268 | { return reverse_iterator(end()); } |
269 | ||
270 | const_reverse_iterator | |
d3677132 | 271 | rbegin() const _GLIBCXX_NOEXCEPT |
a1360f57 SR |
272 | { return const_reverse_iterator(end()); } |
273 | ||
274 | reverse_iterator | |
d3677132 | 275 | rend() _GLIBCXX_NOEXCEPT |
a1360f57 SR |
276 | { return reverse_iterator(begin()); } |
277 | ||
278 | const_reverse_iterator | |
d3677132 | 279 | rend() const _GLIBCXX_NOEXCEPT |
a1360f57 SR |
280 | { return const_reverse_iterator(begin()); } |
281 | ||
734f5023 | 282 | #if __cplusplus >= 201103L |
a1360f57 | 283 | const_iterator |
d3677132 | 284 | cbegin() const noexcept |
a1360f57 SR |
285 | { return const_iterator(_Base::begin(), this); } |
286 | ||
287 | const_iterator | |
d3677132 | 288 | cend() const noexcept |
a1360f57 SR |
289 | { return const_iterator(_Base::end(), this); } |
290 | ||
291 | const_reverse_iterator | |
d3677132 | 292 | crbegin() const noexcept |
a1360f57 SR |
293 | { return const_reverse_iterator(end()); } |
294 | ||
295 | const_reverse_iterator | |
d3677132 | 296 | crend() const noexcept |
a1360f57 SR |
297 | { return const_reverse_iterator(begin()); } |
298 | #endif | |
299 | ||
1218d701 | 300 | // 23.2.4.2 capacity: |
1218d701 | 301 | |
734f5023 | 302 | #if __cplusplus >= 201103L |
dc2cf706 PC |
303 | void |
304 | resize(size_type __sz) | |
305 | { | |
b12db708 | 306 | __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); |
f3de79d4 FD |
307 | _M_profile_resize(this->capacity(), __sz); |
308 | _Base::resize(__sz); | |
dc2cf706 PC |
309 | } |
310 | ||
311 | void | |
312 | resize(size_type __sz, const _Tp& __c) | |
313 | { | |
b12db708 | 314 | __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); |
f3de79d4 FD |
315 | _M_profile_resize(this->capacity(), __sz); |
316 | _Base::resize(__sz, __c); | |
dc2cf706 PC |
317 | } |
318 | #else | |
1218d701 SR |
319 | void |
320 | resize(size_type __sz, _Tp __c = _Tp()) | |
321 | { | |
b12db708 | 322 | __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); |
f3de79d4 FD |
323 | _M_profile_resize(this->capacity(), __sz); |
324 | _Base::resize(__sz, __c); | |
1218d701 | 325 | } |
dc2cf706 | 326 | #endif |
1218d701 | 327 | |
1218d701 SR |
328 | // element access: |
329 | reference | |
757b1644 | 330 | operator[](size_type __n) _GLIBCXX_NOEXCEPT |
1218d701 | 331 | { |
b12db708 | 332 | __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); |
f3de79d4 | 333 | return _M_base()[__n]; |
1218d701 SR |
334 | } |
335 | const_reference | |
757b1644 | 336 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT |
1218d701 | 337 | { |
b12db708 | 338 | __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); |
f3de79d4 | 339 | return _M_base()[__n]; |
1218d701 SR |
340 | } |
341 | ||
1218d701 SR |
342 | // 23.2.4.3 modifiers: |
343 | void | |
344 | push_back(const _Tp& __x) | |
345 | { | |
f3de79d4 | 346 | size_type __old_size = this->capacity(); |
1218d701 | 347 | _Base::push_back(__x); |
f3de79d4 | 348 | _M_profile_resize(__old_size, this->capacity()); |
1218d701 SR |
349 | } |
350 | ||
734f5023 | 351 | #if __cplusplus >= 201103L |
1218d701 SR |
352 | void |
353 | push_back(_Tp&& __x) | |
354 | { | |
f3de79d4 FD |
355 | size_type __old_size = this->capacity(); |
356 | _Base::push_back(std::move(__x)); | |
357 | _M_profile_resize(__old_size, this->capacity()); | |
1218d701 SR |
358 | } |
359 | ||
360 | #endif | |
361 | ||
362 | iterator | |
7b61c5a9 | 363 | #if __cplusplus >= 201103L |
f3de79d4 | 364 | insert(const_iterator __pos, const _Tp& __x) |
7b61c5a9 | 365 | #else |
f3de79d4 | 366 | insert(iterator __pos, const _Tp& __x) |
7b61c5a9 | 367 | #endif |
1218d701 | 368 | { |
b12db708 FD |
369 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
370 | __pos.base() - _Base::begin(), | |
371 | this->size()); | |
f3de79d4 FD |
372 | size_type __old_size = this->capacity(); |
373 | _Base_iterator __res = _Base::insert(__pos.base(), __x); | |
374 | _M_profile_resize(__old_size, this->capacity()); | |
a1360f57 | 375 | return iterator(__res, this); |
1218d701 SR |
376 | } |
377 | ||
734f5023 | 378 | #if __cplusplus >= 201103L |
1218d701 | 379 | iterator |
f3de79d4 | 380 | insert(const_iterator __pos, _Tp&& __x) |
1218d701 | 381 | { |
b12db708 FD |
382 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
383 | __pos.base() - _Base::cbegin(), | |
384 | this->size()); | |
f3de79d4 FD |
385 | size_type __old_size = this->capacity(); |
386 | _Base_iterator __res = _Base::insert(__pos.base(), __x); | |
387 | _M_profile_resize(__old_size, this->capacity()); | |
a1360f57 | 388 | return iterator(__res, this); |
1218d701 SR |
389 | } |
390 | ||
7b61c5a9 | 391 | template<typename... _Args> |
f3de79d4 FD |
392 | iterator |
393 | emplace(const_iterator __pos, _Args&&... __args) | |
394 | { | |
395 | _Base_iterator __res = _Base::emplace(__pos.base(), | |
06eed9f5 | 396 | std::forward<_Args>(__args)...); |
7b61c5a9 PC |
397 | return iterator(__res, this); |
398 | } | |
399 | ||
06eed9f5 | 400 | iterator |
f3de79d4 FD |
401 | insert(const_iterator __pos, initializer_list<value_type> __l) |
402 | { return this->insert(__pos, __l.begin(), __l.end()); } | |
a1360f57 | 403 | #endif |
1218d701 | 404 | |
a1360f57 | 405 | void |
1218d701 | 406 | swap(vector& __x) |
734f5023 | 407 | #if __cplusplus >= 201103L |
f3de79d4 | 408 | noexcept( noexcept(declval<_Base>().swap(__x)) ) |
42500675 | 409 | #endif |
b12db708 FD |
410 | { |
411 | _Base::swap(__x); | |
412 | this->_M_swap(__x); | |
413 | } | |
1218d701 | 414 | |
06eed9f5 PC |
415 | #if __cplusplus >= 201103L |
416 | iterator | |
f3de79d4 | 417 | insert(const_iterator __pos, size_type __n, const _Tp& __x) |
06eed9f5 | 418 | { |
b12db708 FD |
419 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
420 | __pos.base() - _Base::cbegin(), | |
421 | this->size()); | |
f3de79d4 FD |
422 | size_type __old_size = this->capacity(); |
423 | _Base_iterator __res = _Base::insert(__pos, __n, __x); | |
424 | _M_profile_resize(__old_size, this->capacity()); | |
06eed9f5 PC |
425 | return iterator(__res, this); |
426 | } | |
427 | #else | |
1218d701 | 428 | void |
f3de79d4 | 429 | insert(iterator __pos, size_type __n, const _Tp& __x) |
1218d701 | 430 | { |
b12db708 FD |
431 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
432 | __pos.base() - _Base::begin(), | |
433 | this->size()); | |
f3de79d4 FD |
434 | size_type __old_size = this->capacity(); |
435 | _Base::insert(__pos, __n, __x); | |
436 | _M_profile_resize(__old_size, this->capacity()); | |
1218d701 | 437 | } |
06eed9f5 | 438 | #endif |
1218d701 | 439 | |
734f5023 | 440 | #if __cplusplus >= 201103L |
3c7d8b03 JW |
441 | template<typename _InputIterator, |
442 | typename = std::_RequireInputIter<_InputIterator>> | |
06eed9f5 | 443 | iterator |
f3de79d4 | 444 | insert(const_iterator __pos, |
06eed9f5 | 445 | _InputIterator __first, _InputIterator __last) |
f3de79d4 | 446 | { |
b12db708 FD |
447 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
448 | __pos.base() - _Base::cbegin(), | |
449 | this->size()); | |
06eed9f5 | 450 | size_type __old_size = this->capacity(); |
f3de79d4 FD |
451 | _Base_iterator __res = _Base::insert(__pos, __first, __last); |
452 | _M_profile_resize(__old_size, this->capacity()); | |
06eed9f5 PC |
453 | return iterator(__res, this); |
454 | } | |
3c7d8b03 JW |
455 | #else |
456 | template<typename _InputIterator> | |
06eed9f5 | 457 | void |
f3de79d4 | 458 | insert(iterator __pos, |
06eed9f5 | 459 | _InputIterator __first, _InputIterator __last) |
f3de79d4 | 460 | { |
b12db708 FD |
461 | __profcxx_vector2list_insert(this->_M_vect2list_info, |
462 | __pos.base() - _Base::begin(), | |
463 | this->size()); | |
06eed9f5 | 464 | size_type __old_size = this->capacity(); |
f3de79d4 FD |
465 | _Base::insert(__pos, __first, __last); |
466 | _M_profile_resize(__old_size, this->capacity()); | |
06eed9f5 | 467 | } |
3c7d8b03 | 468 | #endif |
1218d701 | 469 | |
a1360f57 | 470 | iterator |
94938aec | 471 | #if __cplusplus >= 201103L |
f3de79d4 | 472 | erase(const_iterator __pos) |
94938aec | 473 | #else |
f3de79d4 | 474 | erase(iterator __pos) |
94938aec | 475 | #endif |
f3de79d4 | 476 | { return iterator(_Base::erase(__pos.base()), this); } |
a1360f57 SR |
477 | |
478 | iterator | |
94938aec PC |
479 | #if __cplusplus >= 201103L |
480 | erase(const_iterator __first, const_iterator __last) | |
481 | #else | |
a1360f57 | 482 | erase(iterator __first, iterator __last) |
94938aec | 483 | #endif |
f3de79d4 | 484 | { return iterator(_Base::erase(__first.base(), __last.base()), this); } |
a1360f57 | 485 | |
1218d701 | 486 | void |
d3677132 | 487 | clear() _GLIBCXX_NOEXCEPT |
1218d701 | 488 | { |
f3de79d4 FD |
489 | this->_M_profile_destruct(); |
490 | _Base::clear(); | |
b12db708 | 491 | this->_M_profile_construct(); |
1218d701 SR |
492 | } |
493 | ||
b12db708 FD |
494 | inline void |
495 | _M_profile_iterate(int __rewind = 0) const | |
496 | { __profcxx_vector2list_iterate(this->_M_vect2list_info, __rewind); } | |
1218d701 SR |
497 | |
498 | private: | |
f3de79d4 | 499 | void _M_profile_resize(size_type __old_size, size_type __new_size) |
1218d701 | 500 | { |
f3de79d4 FD |
501 | if (__old_size < __new_size) |
502 | { | |
b12db708 FD |
503 | __profcxx_vector_size_resize(this->_M_size_info, |
504 | this->size(), __new_size); | |
505 | __profcxx_vector2list_resize(this->_M_vect2list_info, | |
506 | this->size(), __new_size); | |
f3de79d4 | 507 | } |
1218d701 SR |
508 | } |
509 | }; | |
510 | ||
511 | template<typename _Tp, typename _Alloc> | |
512 | inline bool | |
513 | operator==(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 514 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
515 | { return __lhs._M_base() == __rhs._M_base(); } |
516 | ||
517 | template<typename _Tp, typename _Alloc> | |
518 | inline bool | |
519 | operator!=(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 520 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
521 | { return __lhs._M_base() != __rhs._M_base(); } |
522 | ||
523 | template<typename _Tp, typename _Alloc> | |
524 | inline bool | |
525 | operator<(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 526 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
527 | { return __lhs._M_base() < __rhs._M_base(); } |
528 | ||
529 | template<typename _Tp, typename _Alloc> | |
530 | inline bool | |
531 | operator<=(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 532 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
533 | { return __lhs._M_base() <= __rhs._M_base(); } |
534 | ||
535 | template<typename _Tp, typename _Alloc> | |
536 | inline bool | |
537 | operator>=(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 538 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
539 | { return __lhs._M_base() >= __rhs._M_base(); } |
540 | ||
541 | template<typename _Tp, typename _Alloc> | |
542 | inline bool | |
543 | operator>(const vector<_Tp, _Alloc>& __lhs, | |
f3de79d4 | 544 | const vector<_Tp, _Alloc>& __rhs) |
1218d701 SR |
545 | { return __lhs._M_base() > __rhs._M_base(); } |
546 | ||
547 | template<typename _Tp, typename _Alloc> | |
548 | inline void | |
549 | swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) | |
c5d9ec56 | 550 | _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) |
1218d701 SR |
551 | { __lhs.swap(__rhs); } |
552 | ||
553 | } // namespace __profile | |
4cd533a7 | 554 | |
734f5023 | 555 | #if __cplusplus >= 201103L |
4cd533a7 PC |
556 | // DR 1182. |
557 | /// std::hash specialization for vector<bool>. | |
558 | template<typename _Alloc> | |
559 | struct hash<__profile::vector<bool, _Alloc>> | |
5d64ee19 | 560 | : public __hash_base<size_t, __profile::vector<bool, _Alloc>> |
4cd533a7 PC |
561 | { |
562 | size_t | |
72f1c34b | 563 | operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept |
b12db708 FD |
564 | { |
565 | return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()(__b._M_base()); | |
566 | } | |
4cd533a7 PC |
567 | }; |
568 | #endif | |
569 | ||
1218d701 SR |
570 | } // namespace std |
571 | ||
572 | #endif |