136ac495dSmrg// Profiling vector implementation -*- C++ -*- 236ac495dSmrg 3*c0a68be4Smrg// Copyright (C) 2009-2019 Free Software Foundation, Inc. 436ac495dSmrg// 536ac495dSmrg// This file is part of the GNU ISO C++ Library. This library is free 636ac495dSmrg// software; you can redistribute it and/or modify it under the 736ac495dSmrg// terms of the GNU General Public License as published by the 836ac495dSmrg// Free Software Foundation; either version 3, or (at your option) 936ac495dSmrg// any later version. 1036ac495dSmrg// 1136ac495dSmrg// This library is distributed in the hope that it will be useful, 1236ac495dSmrg// but WITHOUT ANY WARRANTY; without even the implied warranty of 1336ac495dSmrg// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1436ac495dSmrg// GNU General Public License for more details. 1536ac495dSmrg 1636ac495dSmrg// Under Section 7 of GPL version 3, you are granted additional 1736ac495dSmrg// permissions described in the GCC Runtime Library Exception, version 1836ac495dSmrg// 3.1, as published by the Free Software Foundation. 1936ac495dSmrg 2036ac495dSmrg// You should have received a copy of the GNU General Public License along 2136ac495dSmrg// with this library; see the file COPYING3. If not see 2236ac495dSmrg// <http://www.gnu.org/licenses/>. 2336ac495dSmrg 2436ac495dSmrg/** @file profile/vector 2536ac495dSmrg * This file is a GNU profile extension to the Standard C++ Library. 2636ac495dSmrg */ 2736ac495dSmrg 2836ac495dSmrg#ifndef _GLIBCXX_PROFILE_VECTOR 2936ac495dSmrg#define _GLIBCXX_PROFILE_VECTOR 1 3036ac495dSmrg 3136ac495dSmrg#include <vector> 3236ac495dSmrg#include <utility> 3336ac495dSmrg#include <profile/base.h> 3436ac495dSmrg#include <profile/iterator_tracker.h> 3536ac495dSmrg 3636ac495dSmrgnamespace std _GLIBCXX_VISIBILITY(default) 3736ac495dSmrg{ 3836ac495dSmrgnamespace __profile 3936ac495dSmrg{ 4036ac495dSmrg template<typename _Vector> 4136ac495dSmrg class _Vector_profile_pre 4236ac495dSmrg { 4336ac495dSmrg _Vector& 4436ac495dSmrg _M_conjure() 4536ac495dSmrg { return *static_cast<_Vector*>(this); } 4636ac495dSmrg 4736ac495dSmrg public: 4836ac495dSmrg#if __cplusplus >= 201103L 4936ac495dSmrg _Vector_profile_pre() = default; 5036ac495dSmrg _Vector_profile_pre(const _Vector_profile_pre&) = default; 5136ac495dSmrg _Vector_profile_pre(_Vector_profile_pre&&) = default; 5236ac495dSmrg 5336ac495dSmrg _Vector_profile_pre& 5436ac495dSmrg operator=(const _Vector_profile_pre&) 5536ac495dSmrg { _M_conjure()._M_profile_destruct(); } 5636ac495dSmrg 5736ac495dSmrg _Vector_profile_pre& 5836ac495dSmrg operator=(_Vector_profile_pre&&) noexcept 5936ac495dSmrg { _M_conjure()._M_profile_destruct(); } 6036ac495dSmrg#endif 6136ac495dSmrg }; 6236ac495dSmrg 6336ac495dSmrg template<typename _Vector> 6436ac495dSmrg class _Vector_profile_post 6536ac495dSmrg { 6636ac495dSmrg _Vector& 6736ac495dSmrg _M_conjure() 6836ac495dSmrg { return *static_cast<_Vector*>(this); } 6936ac495dSmrg 7036ac495dSmrg protected: 7136ac495dSmrg __gnu_profile::__container_size_info* _M_size_info; 7236ac495dSmrg __gnu_profile::__vector2list_info* _M_vect2list_info; 7336ac495dSmrg 7436ac495dSmrg _Vector_profile_post() _GLIBCXX_NOEXCEPT 7536ac495dSmrg { _M_profile_construct(); } 7636ac495dSmrg 7736ac495dSmrg#if __cplusplus >= 201103L 7836ac495dSmrg _Vector_profile_post(const _Vector_profile_post&) noexcept 7936ac495dSmrg : _Vector_profile_post() { } 8036ac495dSmrg _Vector_profile_post(_Vector_profile_post&& __other) noexcept 8136ac495dSmrg : _Vector_profile_post() 8236ac495dSmrg { _M_swap(__other); } 8336ac495dSmrg 8436ac495dSmrg _Vector_profile_post& 8536ac495dSmrg operator=(const _Vector_profile_post&) noexcept 8636ac495dSmrg { _M_profile_construct(); } 8736ac495dSmrg 8836ac495dSmrg _Vector_profile_post& 8936ac495dSmrg operator=(_Vector_profile_post&& __other) noexcept 9036ac495dSmrg { 9136ac495dSmrg _M_swap(__other); 9236ac495dSmrg __other._M_profile_construct(); 9336ac495dSmrg } 9436ac495dSmrg#endif 9536ac495dSmrg 9636ac495dSmrg ~_Vector_profile_post() 9736ac495dSmrg { _M_conjure()._M_profile_destruct(); } 9836ac495dSmrg 9936ac495dSmrg public: 10036ac495dSmrg void 10136ac495dSmrg _M_profile_construct() _GLIBCXX_NOEXCEPT 10236ac495dSmrg { 10336ac495dSmrg _M_size_info = 10436ac495dSmrg __profcxx_vector_size_construct(_M_conjure().capacity()); 10536ac495dSmrg _M_vect2list_info = __profcxx_vector2list_construct(); 10636ac495dSmrg } 10736ac495dSmrg 10836ac495dSmrg void 10936ac495dSmrg _M_profile_destruct() _GLIBCXX_NOEXCEPT 11036ac495dSmrg { 11136ac495dSmrg __profcxx_vector2list_destruct(_M_vect2list_info); 11236ac495dSmrg _M_vect2list_info = 0; 11336ac495dSmrg __profcxx_vector_size_destruct(_M_size_info, 11436ac495dSmrg _M_conjure().capacity(), 11536ac495dSmrg _M_conjure().size()); 11636ac495dSmrg _M_size_info = 0; 11736ac495dSmrg } 11836ac495dSmrg 11936ac495dSmrg void 12036ac495dSmrg _M_swap(_Vector_profile_post& __other) _GLIBCXX_NOEXCEPT 12136ac495dSmrg { 12236ac495dSmrg std::swap(_M_size_info, __other._M_size_info); 12336ac495dSmrg std::swap(_M_vect2list_info, __other._M_vect2list_info); 12436ac495dSmrg } 12536ac495dSmrg }; 12636ac495dSmrg 12736ac495dSmrg template<typename _Tp, 12836ac495dSmrg typename _Allocator = std::allocator<_Tp> > 12936ac495dSmrg class vector 13036ac495dSmrg : public _Vector_profile_pre<vector<_Tp, _Allocator> >, 13136ac495dSmrg public _GLIBCXX_STD_C::vector<_Tp, _Allocator>, 13236ac495dSmrg public _Vector_profile_post<vector<_Tp, _Allocator> > 13336ac495dSmrg { 13436ac495dSmrg typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base; 13536ac495dSmrg 13636ac495dSmrg typedef typename _Base::iterator _Base_iterator; 13736ac495dSmrg typedef typename _Base::const_iterator _Base_const_iterator; 13836ac495dSmrg 13936ac495dSmrg public: 14036ac495dSmrg typedef typename _Base::reference reference; 14136ac495dSmrg typedef typename _Base::const_reference const_reference; 14236ac495dSmrg 14336ac495dSmrg typedef __iterator_tracker<_Base_iterator, vector> 14436ac495dSmrg iterator; 14536ac495dSmrg typedef __iterator_tracker<_Base_const_iterator, vector> 14636ac495dSmrg const_iterator; 14736ac495dSmrg 14836ac495dSmrg typedef typename _Base::size_type size_type; 14936ac495dSmrg typedef typename _Base::difference_type difference_type; 15036ac495dSmrg 15136ac495dSmrg typedef _Tp value_type; 15236ac495dSmrg typedef _Allocator allocator_type; 15336ac495dSmrg typedef typename _Base::pointer pointer; 15436ac495dSmrg typedef typename _Base::const_pointer const_pointer; 15536ac495dSmrg typedef std::reverse_iterator<iterator> reverse_iterator; 15636ac495dSmrg typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 15736ac495dSmrg 15836ac495dSmrg _Base& 15936ac495dSmrg _M_base() _GLIBCXX_NOEXCEPT { return *this; } 16036ac495dSmrg 16136ac495dSmrg const _Base& 16236ac495dSmrg _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 16336ac495dSmrg 16436ac495dSmrg // 23.2.4.1 construct/copy/destroy: 16536ac495dSmrg 16636ac495dSmrg#if __cplusplus < 201103L 16736ac495dSmrg vector() 16836ac495dSmrg { } 16936ac495dSmrg 17036ac495dSmrg vector(const vector& __x) 17136ac495dSmrg : _Base(__x) { } 17236ac495dSmrg#else 17336ac495dSmrg vector() = default; 17436ac495dSmrg vector(const vector&) = default; 17536ac495dSmrg vector(vector&&) = default; 17636ac495dSmrg#endif 17736ac495dSmrg 17836ac495dSmrg explicit 17936ac495dSmrg vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT 18036ac495dSmrg : _Base(__a) { } 18136ac495dSmrg 18236ac495dSmrg#if __cplusplus >= 201103L 18336ac495dSmrg explicit 18436ac495dSmrg vector(size_type __n, const _Allocator& __a = _Allocator()) 18536ac495dSmrg : _Base(__n, __a) { } 18636ac495dSmrg 18736ac495dSmrg vector(size_type __n, const _Tp& __value, 18836ac495dSmrg const _Allocator& __a = _Allocator()) 18936ac495dSmrg : _Base(__n, __value, __a) { } 19036ac495dSmrg#else 19136ac495dSmrg explicit 19236ac495dSmrg vector(size_type __n, const _Tp& __value = _Tp(), 19336ac495dSmrg const _Allocator& __a = _Allocator()) 19436ac495dSmrg : _Base(__n, __value, __a) { } 19536ac495dSmrg#endif 19636ac495dSmrg 19736ac495dSmrg#if __cplusplus >= 201103L 19836ac495dSmrg template<typename _InputIterator, 19936ac495dSmrg typename = std::_RequireInputIter<_InputIterator>> 20036ac495dSmrg#else 20136ac495dSmrg template<typename _InputIterator> 20236ac495dSmrg#endif 20336ac495dSmrg vector(_InputIterator __first, _InputIterator __last, 20436ac495dSmrg const _Allocator& __a = _Allocator()) 20536ac495dSmrg : _Base(__first, __last, __a) { } 20636ac495dSmrg 20736ac495dSmrg /// Construction from a normal-mode vector 20836ac495dSmrg vector(const _Base& __x) 20936ac495dSmrg : _Base(__x) { } 21036ac495dSmrg 21136ac495dSmrg#if __cplusplus >= 201103L 21236ac495dSmrg vector(const _Base& __x, const _Allocator& __a) 21336ac495dSmrg : _Base(__x, __a) { } 21436ac495dSmrg 21536ac495dSmrg vector(vector&& __x, const _Allocator& __a) 21636ac495dSmrg : _Base(std::move(__x), __a) { } 21736ac495dSmrg 21836ac495dSmrg vector(initializer_list<value_type> __l, 21936ac495dSmrg const allocator_type& __a = allocator_type()) 22036ac495dSmrg : _Base(__l, __a) { } 22136ac495dSmrg#endif 22236ac495dSmrg 22336ac495dSmrg#if __cplusplus < 201103L 22436ac495dSmrg vector& 22536ac495dSmrg operator=(const vector& __x) 22636ac495dSmrg { 22736ac495dSmrg this->_M_profile_destruct(); 22836ac495dSmrg _M_base() = __x; 22936ac495dSmrg this->_M_profile_construct(); 23036ac495dSmrg return *this; 23136ac495dSmrg } 23236ac495dSmrg#else 23336ac495dSmrg vector& 23436ac495dSmrg operator=(const vector&) = default; 23536ac495dSmrg 23636ac495dSmrg vector& 23736ac495dSmrg operator=(vector&&) = default; 23836ac495dSmrg 23936ac495dSmrg vector& 24036ac495dSmrg operator=(initializer_list<value_type> __l) 24136ac495dSmrg { 24236ac495dSmrg this->_M_profile_destruct(); 24336ac495dSmrg _M_base() = __l; 24436ac495dSmrg this->_M_profile_construct(); 24536ac495dSmrg return *this; 24636ac495dSmrg } 24736ac495dSmrg#endif 24836ac495dSmrg 24936ac495dSmrg // iterators: 25036ac495dSmrg iterator 25136ac495dSmrg begin() _GLIBCXX_NOEXCEPT 25236ac495dSmrg { return iterator(_Base::begin(), this); } 25336ac495dSmrg 25436ac495dSmrg const_iterator 25536ac495dSmrg begin() const _GLIBCXX_NOEXCEPT 25636ac495dSmrg { return const_iterator(_Base::begin(), this); } 25736ac495dSmrg 25836ac495dSmrg iterator 25936ac495dSmrg end() _GLIBCXX_NOEXCEPT 26036ac495dSmrg { return iterator(_Base::end(), this); } 26136ac495dSmrg 26236ac495dSmrg const_iterator 26336ac495dSmrg end() const _GLIBCXX_NOEXCEPT 26436ac495dSmrg { return const_iterator(_Base::end(), this); } 26536ac495dSmrg 26636ac495dSmrg reverse_iterator 26736ac495dSmrg rbegin() _GLIBCXX_NOEXCEPT 26836ac495dSmrg { return reverse_iterator(end()); } 26936ac495dSmrg 27036ac495dSmrg const_reverse_iterator 27136ac495dSmrg rbegin() const _GLIBCXX_NOEXCEPT 27236ac495dSmrg { return const_reverse_iterator(end()); } 27336ac495dSmrg 27436ac495dSmrg reverse_iterator 27536ac495dSmrg rend() _GLIBCXX_NOEXCEPT 27636ac495dSmrg { return reverse_iterator(begin()); } 27736ac495dSmrg 27836ac495dSmrg const_reverse_iterator 27936ac495dSmrg rend() const _GLIBCXX_NOEXCEPT 28036ac495dSmrg { return const_reverse_iterator(begin()); } 28136ac495dSmrg 28236ac495dSmrg#if __cplusplus >= 201103L 28336ac495dSmrg const_iterator 28436ac495dSmrg cbegin() const noexcept 28536ac495dSmrg { return const_iterator(_Base::begin(), this); } 28636ac495dSmrg 28736ac495dSmrg const_iterator 28836ac495dSmrg cend() const noexcept 28936ac495dSmrg { return const_iterator(_Base::end(), this); } 29036ac495dSmrg 29136ac495dSmrg const_reverse_iterator 29236ac495dSmrg crbegin() const noexcept 29336ac495dSmrg { return const_reverse_iterator(end()); } 29436ac495dSmrg 29536ac495dSmrg const_reverse_iterator 29636ac495dSmrg crend() const noexcept 29736ac495dSmrg { return const_reverse_iterator(begin()); } 29836ac495dSmrg#endif 29936ac495dSmrg 30036ac495dSmrg // 23.2.4.2 capacity: 30136ac495dSmrg 30236ac495dSmrg#if __cplusplus >= 201103L 30336ac495dSmrg void 30436ac495dSmrg resize(size_type __sz) 30536ac495dSmrg { 30636ac495dSmrg __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); 30736ac495dSmrg _M_profile_resize(this->capacity(), __sz); 30836ac495dSmrg _Base::resize(__sz); 30936ac495dSmrg } 31036ac495dSmrg 31136ac495dSmrg void 31236ac495dSmrg resize(size_type __sz, const _Tp& __c) 31336ac495dSmrg { 31436ac495dSmrg __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); 31536ac495dSmrg _M_profile_resize(this->capacity(), __sz); 31636ac495dSmrg _Base::resize(__sz, __c); 31736ac495dSmrg } 31836ac495dSmrg#else 31936ac495dSmrg void 32036ac495dSmrg resize(size_type __sz, _Tp __c = _Tp()) 32136ac495dSmrg { 32236ac495dSmrg __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); 32336ac495dSmrg _M_profile_resize(this->capacity(), __sz); 32436ac495dSmrg _Base::resize(__sz, __c); 32536ac495dSmrg } 32636ac495dSmrg#endif 32736ac495dSmrg 32836ac495dSmrg // element access: 32936ac495dSmrg reference 33036ac495dSmrg operator[](size_type __n) _GLIBCXX_NOEXCEPT 33136ac495dSmrg { 33236ac495dSmrg __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); 33336ac495dSmrg return _M_base()[__n]; 33436ac495dSmrg } 33536ac495dSmrg const_reference 33636ac495dSmrg operator[](size_type __n) const _GLIBCXX_NOEXCEPT 33736ac495dSmrg { 33836ac495dSmrg __profcxx_vector2list_invalid_operator(this->_M_vect2list_info); 33936ac495dSmrg return _M_base()[__n]; 34036ac495dSmrg } 34136ac495dSmrg 34236ac495dSmrg // 23.2.4.3 modifiers: 34336ac495dSmrg void 34436ac495dSmrg push_back(const _Tp& __x) 34536ac495dSmrg { 34636ac495dSmrg size_type __old_size = this->capacity(); 34736ac495dSmrg _Base::push_back(__x); 34836ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 34936ac495dSmrg } 35036ac495dSmrg 35136ac495dSmrg#if __cplusplus >= 201103L 35236ac495dSmrg void 35336ac495dSmrg push_back(_Tp&& __x) 35436ac495dSmrg { 35536ac495dSmrg size_type __old_size = this->capacity(); 35636ac495dSmrg _Base::push_back(std::move(__x)); 35736ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 35836ac495dSmrg } 35936ac495dSmrg 36036ac495dSmrg#endif 36136ac495dSmrg 36236ac495dSmrg iterator 36336ac495dSmrg#if __cplusplus >= 201103L 36436ac495dSmrg insert(const_iterator __pos, const _Tp& __x) 36536ac495dSmrg#else 36636ac495dSmrg insert(iterator __pos, const _Tp& __x) 36736ac495dSmrg#endif 36836ac495dSmrg { 36936ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 37036ac495dSmrg __pos.base() - _Base::begin(), 37136ac495dSmrg this->size()); 37236ac495dSmrg size_type __old_size = this->capacity(); 37336ac495dSmrg _Base_iterator __res = _Base::insert(__pos.base(), __x); 37436ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 37536ac495dSmrg return iterator(__res, this); 37636ac495dSmrg } 37736ac495dSmrg 37836ac495dSmrg#if __cplusplus >= 201103L 37936ac495dSmrg iterator 38036ac495dSmrg insert(const_iterator __pos, _Tp&& __x) 38136ac495dSmrg { 38236ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 38336ac495dSmrg __pos.base() - _Base::cbegin(), 38436ac495dSmrg this->size()); 38536ac495dSmrg size_type __old_size = this->capacity(); 38636ac495dSmrg _Base_iterator __res = _Base::insert(__pos.base(), __x); 38736ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 38836ac495dSmrg return iterator(__res, this); 38936ac495dSmrg } 39036ac495dSmrg 39136ac495dSmrg template<typename... _Args> 39236ac495dSmrg iterator 39336ac495dSmrg emplace(const_iterator __pos, _Args&&... __args) 39436ac495dSmrg { 39536ac495dSmrg _Base_iterator __res = _Base::emplace(__pos.base(), 39636ac495dSmrg std::forward<_Args>(__args)...); 39736ac495dSmrg return iterator(__res, this); 39836ac495dSmrg } 39936ac495dSmrg 40036ac495dSmrg iterator 40136ac495dSmrg insert(const_iterator __pos, initializer_list<value_type> __l) 40236ac495dSmrg { return this->insert(__pos, __l.begin(), __l.end()); } 40336ac495dSmrg#endif 40436ac495dSmrg 40536ac495dSmrg void 40636ac495dSmrg swap(vector& __x) 40736ac495dSmrg#if __cplusplus >= 201103L 40836ac495dSmrg noexcept( noexcept(declval<_Base>().swap(__x)) ) 40936ac495dSmrg#endif 41036ac495dSmrg { 41136ac495dSmrg _Base::swap(__x); 41236ac495dSmrg this->_M_swap(__x); 41336ac495dSmrg } 41436ac495dSmrg 41536ac495dSmrg#if __cplusplus >= 201103L 41636ac495dSmrg iterator 41736ac495dSmrg insert(const_iterator __pos, size_type __n, const _Tp& __x) 41836ac495dSmrg { 41936ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 42036ac495dSmrg __pos.base() - _Base::cbegin(), 42136ac495dSmrg this->size()); 42236ac495dSmrg size_type __old_size = this->capacity(); 42336ac495dSmrg _Base_iterator __res = _Base::insert(__pos, __n, __x); 42436ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 42536ac495dSmrg return iterator(__res, this); 42636ac495dSmrg } 42736ac495dSmrg#else 42836ac495dSmrg void 42936ac495dSmrg insert(iterator __pos, size_type __n, const _Tp& __x) 43036ac495dSmrg { 43136ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 43236ac495dSmrg __pos.base() - _Base::begin(), 43336ac495dSmrg this->size()); 43436ac495dSmrg size_type __old_size = this->capacity(); 43536ac495dSmrg _Base::insert(__pos, __n, __x); 43636ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 43736ac495dSmrg } 43836ac495dSmrg#endif 43936ac495dSmrg 44036ac495dSmrg#if __cplusplus >= 201103L 44136ac495dSmrg template<typename _InputIterator, 44236ac495dSmrg typename = std::_RequireInputIter<_InputIterator>> 44336ac495dSmrg iterator 44436ac495dSmrg insert(const_iterator __pos, 44536ac495dSmrg _InputIterator __first, _InputIterator __last) 44636ac495dSmrg { 44736ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 44836ac495dSmrg __pos.base() - _Base::cbegin(), 44936ac495dSmrg this->size()); 45036ac495dSmrg size_type __old_size = this->capacity(); 45136ac495dSmrg _Base_iterator __res = _Base::insert(__pos, __first, __last); 45236ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 45336ac495dSmrg return iterator(__res, this); 45436ac495dSmrg } 45536ac495dSmrg#else 45636ac495dSmrg template<typename _InputIterator> 45736ac495dSmrg void 45836ac495dSmrg insert(iterator __pos, 45936ac495dSmrg _InputIterator __first, _InputIterator __last) 46036ac495dSmrg { 46136ac495dSmrg __profcxx_vector2list_insert(this->_M_vect2list_info, 46236ac495dSmrg __pos.base() - _Base::begin(), 46336ac495dSmrg this->size()); 46436ac495dSmrg size_type __old_size = this->capacity(); 46536ac495dSmrg _Base::insert(__pos, __first, __last); 46636ac495dSmrg _M_profile_resize(__old_size, this->capacity()); 46736ac495dSmrg } 46836ac495dSmrg#endif 46936ac495dSmrg 47036ac495dSmrg iterator 47136ac495dSmrg#if __cplusplus >= 201103L 47236ac495dSmrg erase(const_iterator __pos) 47336ac495dSmrg#else 47436ac495dSmrg erase(iterator __pos) 47536ac495dSmrg#endif 47636ac495dSmrg { return iterator(_Base::erase(__pos.base()), this); } 47736ac495dSmrg 47836ac495dSmrg iterator 47936ac495dSmrg#if __cplusplus >= 201103L 48036ac495dSmrg erase(const_iterator __first, const_iterator __last) 48136ac495dSmrg#else 48236ac495dSmrg erase(iterator __first, iterator __last) 48336ac495dSmrg#endif 48436ac495dSmrg { return iterator(_Base::erase(__first.base(), __last.base()), this); } 48536ac495dSmrg 48636ac495dSmrg void 48736ac495dSmrg clear() _GLIBCXX_NOEXCEPT 48836ac495dSmrg { 48936ac495dSmrg this->_M_profile_destruct(); 49036ac495dSmrg _Base::clear(); 49136ac495dSmrg this->_M_profile_construct(); 49236ac495dSmrg } 49336ac495dSmrg 49436ac495dSmrg inline void 49536ac495dSmrg _M_profile_iterate(int __rewind = 0) const 49636ac495dSmrg { __profcxx_vector2list_iterate(this->_M_vect2list_info, __rewind); } 49736ac495dSmrg 49836ac495dSmrg private: 49936ac495dSmrg void _M_profile_resize(size_type __old_size, size_type __new_size) 50036ac495dSmrg { 50136ac495dSmrg if (__old_size < __new_size) 50236ac495dSmrg { 50336ac495dSmrg __profcxx_vector_size_resize(this->_M_size_info, 50436ac495dSmrg this->size(), __new_size); 50536ac495dSmrg __profcxx_vector2list_resize(this->_M_vect2list_info, 50636ac495dSmrg this->size(), __new_size); 50736ac495dSmrg } 50836ac495dSmrg } 50936ac495dSmrg }; 51036ac495dSmrg 51136ac495dSmrg template<typename _Tp, typename _Alloc> 51236ac495dSmrg inline bool 51336ac495dSmrg operator==(const vector<_Tp, _Alloc>& __lhs, 51436ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 51536ac495dSmrg { return __lhs._M_base() == __rhs._M_base(); } 51636ac495dSmrg 51736ac495dSmrg template<typename _Tp, typename _Alloc> 51836ac495dSmrg inline bool 51936ac495dSmrg operator!=(const vector<_Tp, _Alloc>& __lhs, 52036ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 52136ac495dSmrg { return __lhs._M_base() != __rhs._M_base(); } 52236ac495dSmrg 52336ac495dSmrg template<typename _Tp, typename _Alloc> 52436ac495dSmrg inline bool 52536ac495dSmrg operator<(const vector<_Tp, _Alloc>& __lhs, 52636ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 52736ac495dSmrg { return __lhs._M_base() < __rhs._M_base(); } 52836ac495dSmrg 52936ac495dSmrg template<typename _Tp, typename _Alloc> 53036ac495dSmrg inline bool 53136ac495dSmrg operator<=(const vector<_Tp, _Alloc>& __lhs, 53236ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 53336ac495dSmrg { return __lhs._M_base() <= __rhs._M_base(); } 53436ac495dSmrg 53536ac495dSmrg template<typename _Tp, typename _Alloc> 53636ac495dSmrg inline bool 53736ac495dSmrg operator>=(const vector<_Tp, _Alloc>& __lhs, 53836ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 53936ac495dSmrg { return __lhs._M_base() >= __rhs._M_base(); } 54036ac495dSmrg 54136ac495dSmrg template<typename _Tp, typename _Alloc> 54236ac495dSmrg inline bool 54336ac495dSmrg operator>(const vector<_Tp, _Alloc>& __lhs, 54436ac495dSmrg const vector<_Tp, _Alloc>& __rhs) 54536ac495dSmrg { return __lhs._M_base() > __rhs._M_base(); } 54636ac495dSmrg 54736ac495dSmrg template<typename _Tp, typename _Alloc> 54836ac495dSmrg inline void 54936ac495dSmrg swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) 55036ac495dSmrg _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) 55136ac495dSmrg { __lhs.swap(__rhs); } 55236ac495dSmrg 55336ac495dSmrg} // namespace __profile 55436ac495dSmrg 55536ac495dSmrg#if __cplusplus >= 201103L 55636ac495dSmrg // DR 1182. 55736ac495dSmrg /// std::hash specialization for vector<bool>. 55836ac495dSmrg template<typename _Alloc> 55936ac495dSmrg struct hash<__profile::vector<bool, _Alloc>> 56036ac495dSmrg : public __hash_base<size_t, __profile::vector<bool, _Alloc>> 56136ac495dSmrg { 56236ac495dSmrg size_t 56336ac495dSmrg operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept 56436ac495dSmrg { 56536ac495dSmrg return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()(__b._M_base()); 56636ac495dSmrg } 56736ac495dSmrg }; 56836ac495dSmrg#endif 56936ac495dSmrg 57036ac495dSmrg} // namespace std 57136ac495dSmrg 57236ac495dSmrg#endif 573