28 #ifndef _GLIBCXX_PROFILE_VECTOR
29 #define _GLIBCXX_PROFILE_VECTOR 1
36 namespace std _GLIBCXX_VISIBILITY(default)
40 template<
typename _Tp,
43 :
public _GLIBCXX_STD_C::vector<_Tp, _Allocator>
45 typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
47 typedef typename _Base::iterator _Base_iterator;
48 typedef typename _Base::const_iterator _Base_const_iterator;
50 #if __cplusplus >= 201103L
55 typedef typename _Base::reference reference;
56 typedef typename _Base::const_reference const_reference;
58 typedef __iterator_tracker<_Base_iterator, vector>
60 typedef __iterator_tracker<_Base_const_iterator, vector>
63 typedef typename _Base::size_type size_type;
64 typedef typename _Base::difference_type difference_type;
66 typedef _Tp value_type;
67 typedef _Allocator allocator_type;
68 typedef typename _Base::pointer pointer;
69 typedef typename _Base::const_pointer const_pointer;
74 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
77 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
81 vector(
const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
84 __profcxx_vector_construct(
this, this->capacity());
85 __profcxx_vector_construct2(
this);
88 #if __cplusplus >= 201103L
90 vector(size_type __n,
const _Allocator& __a = _Allocator())
93 __profcxx_vector_construct(
this, this->capacity());
94 __profcxx_vector_construct2(
this);
97 vector(size_type __n,
const _Tp& __value,
98 const _Allocator& __a = _Allocator())
99 : _Base(__n, __value, __a)
101 __profcxx_vector_construct(
this, this->capacity());
102 __profcxx_vector_construct2(
this);
106 vector(size_type __n,
const _Tp& __value = _Tp(),
107 const _Allocator& __a = _Allocator())
108 : _Base(__n, __value, __a)
110 __profcxx_vector_construct(
this, this->capacity());
111 __profcxx_vector_construct2(
this);
115 #if __cplusplus >= 201103L
116 template<
typename _InputIterator,
117 typename = std::_RequireInputIter<_InputIterator>>
119 template<
typename _InputIterator>
121 vector(_InputIterator __first, _InputIterator __last,
122 const _Allocator& __a = _Allocator())
123 : _Base(__first, __last, __a)
125 __profcxx_vector_construct(
this, this->capacity());
126 __profcxx_vector_construct2(
this);
129 vector(
const vector& __x)
132 __profcxx_vector_construct(
this, this->capacity());
133 __profcxx_vector_construct2(
this);
137 vector(
const _Base& __x)
140 __profcxx_vector_construct(
this, this->capacity());
141 __profcxx_vector_construct2(
this);
144 #if __cplusplus >= 201103L
145 vector(vector&& __x) noexcept
146 : _Base(std::move(__x))
148 __profcxx_vector_construct(
this, this->capacity());
149 __profcxx_vector_construct2(
this);
152 vector(
const _Base& __x,
const _Allocator& __a)
155 __profcxx_vector_construct(
this, this->capacity());
156 __profcxx_vector_construct2(
this);
159 vector(vector&& __x,
const _Allocator& __a)
160 : _Base(std::move(__x), __a)
162 __profcxx_vector_construct(
this, this->capacity());
163 __profcxx_vector_construct2(
this);
166 vector(initializer_list<value_type> __l,
167 const allocator_type& __a = allocator_type())
168 : _Base(__l, __a) { }
171 ~vector() _GLIBCXX_NOEXCEPT
173 __profcxx_vector_destruct(
this, this->capacity(), this->
size());
174 __profcxx_vector_destruct2(
this);
178 operator=(
const vector& __x)
180 static_cast<_Base&
>(*this) = __x;
184 #if __cplusplus >= 201103L
186 operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
188 __profcxx_vector_destruct(
this, this->capacity(), this->
size());
189 __profcxx_vector_destruct2(
this);
190 static_cast<_Base&
>(*this) = std::move(__x);
195 operator=(initializer_list<value_type> __l)
197 static_cast<_Base&
>(*this) = __l;
203 using _Base::get_allocator;
208 begin() _GLIBCXX_NOEXCEPT
212 begin() const _GLIBCXX_NOEXCEPT
216 end() _GLIBCXX_NOEXCEPT
220 end() const _GLIBCXX_NOEXCEPT
221 {
return const_iterator(
_Base::end(),
this); }
224 rbegin() _GLIBCXX_NOEXCEPT
225 {
return reverse_iterator(
end()); }
227 const_reverse_iterator
228 rbegin() const _GLIBCXX_NOEXCEPT
229 {
return const_reverse_iterator(
end()); }
232 rend() _GLIBCXX_NOEXCEPT
233 {
return reverse_iterator(
begin()); }
235 const_reverse_iterator
236 rend() const _GLIBCXX_NOEXCEPT
237 {
return const_reverse_iterator(
begin()); }
239 #if __cplusplus >= 201103L
241 cbegin() const noexcept
245 cend() const noexcept
246 {
return const_iterator(
_Base::end(),
this); }
248 const_reverse_iterator
249 crbegin() const noexcept
250 {
return const_reverse_iterator(
end()); }
252 const_reverse_iterator
253 crend() const noexcept
254 {
return const_reverse_iterator(
begin()); }
259 using _Base::max_size;
261 #if __cplusplus >= 201103L
263 resize(size_type __sz)
265 __profcxx_vector_invalid_operator(
this);
266 _M_profile_resize(
this, this->capacity(), __sz);
271 resize(size_type __sz,
const _Tp& __c)
273 __profcxx_vector_invalid_operator(
this);
274 _M_profile_resize(
this, this->capacity(), __sz);
275 _Base::resize(__sz, __c);
279 resize(size_type __sz, _Tp __c = _Tp())
281 __profcxx_vector_invalid_operator(
this);
282 _M_profile_resize(
this, this->capacity(), __sz);
283 _Base::resize(__sz, __c);
287 #if __cplusplus >= 201103L
288 using _Base::shrink_to_fit;
297 __profcxx_vector_invalid_operator(
this);
298 return _M_base()[__n];
301 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
303 __profcxx_vector_invalid_operator(
this);
304 return _M_base()[__n];
310 front() _GLIBCXX_NOEXCEPT
312 return _Base::front();
316 front() const _GLIBCXX_NOEXCEPT
318 return _Base::front();
322 back() _GLIBCXX_NOEXCEPT
324 return _Base::back();
328 back() const _GLIBCXX_NOEXCEPT
330 return _Base::back();
339 push_back(
const _Tp& __x)
341 size_type __old_size = this->capacity();
342 _Base::push_back(__x);
343 _M_profile_resize(
this, __old_size, this->capacity());
346 #if __cplusplus >= 201103L
350 size_type __old_size = this->capacity();
351 _Base::push_back(std::move(__x));
352 _M_profile_resize(
this, __old_size, this->capacity());
358 #if __cplusplus >= 201103L
359 insert(const_iterator __position,
const _Tp& __x)
361 insert(iterator __position,
const _Tp& __x)
364 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
366 size_type __old_size = this->capacity();
367 _Base_iterator __res = _Base::insert(__position.base(), __x);
368 _M_profile_resize(
this, __old_size, this->capacity());
369 return iterator(__res,
this);
372 #if __cplusplus >= 201103L
374 insert(const_iterator __position, _Tp&& __x)
376 __profcxx_vector_insert(
this, __position.base() - _Base::cbegin(),
378 size_type __old_size = this->capacity();
379 _Base_iterator __res = _Base::insert(__position.base(), __x);
380 _M_profile_resize(
this, __old_size, this->capacity());
381 return iterator(__res,
this);
384 template<
typename... _Args>
386 emplace(const_iterator __position, _Args&&... __args)
388 _Base_iterator __res = _Base::emplace(__position.base(),
389 std::forward<_Args>(__args)...);
390 return iterator(__res,
this);
394 insert(const_iterator __position, initializer_list<value_type> __l)
395 {
return this->insert(__position, __l.begin(), __l.end()); }
398 #if __cplusplus >= 201103L
408 #if __cplusplus >= 201103L
409 noexcept(_Alloc_traits::_S_nothrow_swap())
415 #if __cplusplus >= 201103L
417 insert(const_iterator __position, size_type __n,
const _Tp& __x)
419 __profcxx_vector_insert(
this, __position.base() - _Base::cbegin(),
421 size_type __old_size = this->capacity();
422 _Base_iterator __res = _Base::insert(__position, __n, __x);
423 _M_profile_resize(
this, __old_size, this->capacity());
424 return iterator(__res,
this);
428 insert(iterator __position, size_type __n,
const _Tp& __x)
430 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
432 size_type __old_size = this->capacity();
433 _Base::insert(__position, __n, __x);
434 _M_profile_resize(
this, __old_size, this->capacity());
438 #if __cplusplus >= 201103L
439 template<
typename _InputIterator,
440 typename = std::_RequireInputIter<_InputIterator>>
442 insert(const_iterator __position,
443 _InputIterator __first, _InputIterator __last)
445 __profcxx_vector_insert(
this, __position.base() - _Base::cbegin(),
447 size_type __old_size = this->capacity();
448 _Base_iterator __res = _Base::insert(__position, __first, __last);
449 _M_profile_resize(
this, __old_size, this->capacity());
450 return iterator(__res,
this);
453 template<
typename _InputIterator>
455 insert(iterator __position,
456 _InputIterator __first, _InputIterator __last)
458 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
460 size_type __old_size = this->capacity();
461 _Base::insert(__position, __first, __last);
462 _M_profile_resize(
this, __old_size, this->capacity());
467 #if __cplusplus >= 201103L
468 erase(const_iterator __position)
470 erase(iterator __position)
473 _Base_iterator __res = _Base::erase(__position.base());
474 return iterator(__res,
this);
478 #if __cplusplus >= 201103L
479 erase(const_iterator __first, const_iterator __last)
481 erase(iterator __first, iterator __last)
486 _Base_iterator __res = _Base::erase(__first.base(), __last.base());
487 return iterator(__res,
this);
491 clear() _GLIBCXX_NOEXCEPT
493 __profcxx_vector_destruct(
this, this->capacity(), this->
size());
494 __profcxx_vector_destruct2(
this);
498 inline void _M_profile_find()
const
500 __profcxx_vector_find(
this,
size());
503 inline void _M_profile_iterate(
int __rewind = 0)
const
505 __profcxx_vector_iterate(
this);
509 void _M_profile_resize(
void* obj, size_type __old_size,
510 size_type __new_size)
512 if (__old_size < __new_size) {
513 __profcxx_vector_resize(
this, this->
size(), __new_size);
514 __profcxx_vector_resize2(
this, this->
size(), __new_size);
519 template<
typename _Tp,
typename _Alloc>
521 operator==(
const vector<_Tp, _Alloc>& __lhs,
522 const vector<_Tp, _Alloc>& __rhs)
523 {
return __lhs._M_base() == __rhs._M_base(); }
525 template<
typename _Tp,
typename _Alloc>
527 operator!=(
const vector<_Tp, _Alloc>& __lhs,
528 const vector<_Tp, _Alloc>& __rhs)
529 {
return __lhs._M_base() != __rhs._M_base(); }
531 template<
typename _Tp,
typename _Alloc>
533 operator<(const vector<_Tp, _Alloc>& __lhs,
534 const vector<_Tp, _Alloc>& __rhs)
535 {
return __lhs._M_base() < __rhs._M_base(); }
537 template<
typename _Tp,
typename _Alloc>
539 operator<=(const vector<_Tp, _Alloc>& __lhs,
540 const vector<_Tp, _Alloc>& __rhs)
541 {
return __lhs._M_base() <= __rhs._M_base(); }
543 template<
typename _Tp,
typename _Alloc>
545 operator>=(
const vector<_Tp, _Alloc>& __lhs,
546 const vector<_Tp, _Alloc>& __rhs)
547 {
return __lhs._M_base() >= __rhs._M_base(); }
549 template<
typename _Tp,
typename _Alloc>
551 operator>(
const vector<_Tp, _Alloc>& __lhs,
552 const vector<_Tp, _Alloc>& __rhs)
553 {
return __lhs._M_base() > __rhs._M_base(); }
555 template<
typename _Tp,
typename _Alloc>
557 swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs)
558 { __lhs.swap(__rhs); }
560 #if __cplusplus >= 201103L
561 template<
typename _Tp,
typename _Alloc>
563 swap(vector<_Tp, _Alloc>&& __lhs, vector<_Tp, _Alloc>& __rhs)
564 { __lhs.swap(__rhs); }
566 template<
typename _Tp,
typename _Alloc>
568 swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>&& __rhs)
569 { __lhs.swap(__rhs); }
574 #if __cplusplus >= 201103L
577 template<
typename _Alloc>
578 struct hash<__profile::vector<bool, _Alloc>>
579 :
public __hash_base<size_t, __profile::vector<bool, _Alloc>>
582 operator()(
const __profile::vector<bool, _Alloc>& __b)
const noexcept
Uniform interface to C++98 and C++0x allocators.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
constexpr size_t size() const noexcept
Returns the total number of bits.
The standard allocator, as per [20.4].
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
Primary class template hash.
reference operator[](size_t __position)
Array-indexing support.