1*38fd1498Szrj// Profiling list implementation -*- C++ -*- 2*38fd1498Szrj 3*38fd1498Szrj// Copyright (C) 2009-2018 Free Software Foundation, Inc. 4*38fd1498Szrj// 5*38fd1498Szrj// This file is part of the GNU ISO C++ Library. This library is free 6*38fd1498Szrj// software; you can redistribute it and/or modify it under the 7*38fd1498Szrj// terms of the GNU General Public License as published by the 8*38fd1498Szrj// Free Software Foundation; either version 3, or (at your option) 9*38fd1498Szrj// any later version. 10*38fd1498Szrj 11*38fd1498Szrj// This library is distributed in the hope that it will be useful, 12*38fd1498Szrj// but WITHOUT ANY WARRANTY; without even the implied warranty of 13*38fd1498Szrj// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*38fd1498Szrj// GNU General Public License for more details. 15*38fd1498Szrj 16*38fd1498Szrj// Under Section 7 of GPL version 3, you are granted additional 17*38fd1498Szrj// permissions described in the GCC Runtime Library Exception, version 18*38fd1498Szrj// 3.1, as published by the Free Software Foundation. 19*38fd1498Szrj 20*38fd1498Szrj// You should have received a copy of the GNU General Public License and 21*38fd1498Szrj// a copy of the GCC Runtime Library Exception along with this program; 22*38fd1498Szrj// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23*38fd1498Szrj// <http://www.gnu.org/licenses/>. 24*38fd1498Szrj 25*38fd1498Szrj/** @file profile/list 26*38fd1498Szrj * This file is a GNU profile extension to the Standard C++ Library. 27*38fd1498Szrj */ 28*38fd1498Szrj 29*38fd1498Szrj#ifndef _GLIBCXX_PROFILE_LIST 30*38fd1498Szrj#define _GLIBCXX_PROFILE_LIST 1 31*38fd1498Szrj 32*38fd1498Szrj#include <list> 33*38fd1498Szrj#include <profile/base.h> 34*38fd1498Szrj#include <profile/iterator_tracker.h> 35*38fd1498Szrj 36*38fd1498Szrjnamespace std _GLIBCXX_VISIBILITY(default) 37*38fd1498Szrj{ 38*38fd1498Szrjnamespace __profile 39*38fd1498Szrj{ 40*38fd1498Szrj template<typename _List> 41*38fd1498Szrj class _List_profile 42*38fd1498Szrj { 43*38fd1498Szrj _List& 44*38fd1498Szrj _M_conjure() 45*38fd1498Szrj { return *static_cast<_List*>(this); } 46*38fd1498Szrj 47*38fd1498Szrj public: 48*38fd1498Szrj __gnu_profile::__list2slist_info* _M_list2slist_info; 49*38fd1498Szrj __gnu_profile::__list2vector_info* _M_list2vector_info; 50*38fd1498Szrj 51*38fd1498Szrj _List_profile() _GLIBCXX_NOEXCEPT 52*38fd1498Szrj { _M_profile_construct(); } 53*38fd1498Szrj 54*38fd1498Szrj void 55*38fd1498Szrj _M_profile_construct() _GLIBCXX_NOEXCEPT 56*38fd1498Szrj { 57*38fd1498Szrj _M_list2slist_info = __profcxx_list2slist_construct(); 58*38fd1498Szrj _M_list2vector_info = __profcxx_list2vector_construct(); 59*38fd1498Szrj } 60*38fd1498Szrj 61*38fd1498Szrj void 62*38fd1498Szrj _M_profile_destruct() _GLIBCXX_NOEXCEPT 63*38fd1498Szrj { 64*38fd1498Szrj __profcxx_list2vector_destruct(_M_list2vector_info); 65*38fd1498Szrj _M_list2vector_info = 0; 66*38fd1498Szrj __profcxx_list2slist_destruct(_M_list2slist_info); 67*38fd1498Szrj _M_list2slist_info = 0; 68*38fd1498Szrj } 69*38fd1498Szrj 70*38fd1498Szrj void 71*38fd1498Szrj _M_swap(_List_profile& __other) 72*38fd1498Szrj { 73*38fd1498Szrj std::swap(_M_list2slist_info, __other._M_list2slist_info); 74*38fd1498Szrj std::swap(_M_list2vector_info, __other._M_list2vector_info); 75*38fd1498Szrj } 76*38fd1498Szrj 77*38fd1498Szrj#if __cplusplus >= 201103L 78*38fd1498Szrj _List_profile(const _List_profile&) noexcept 79*38fd1498Szrj : _List_profile() { } 80*38fd1498Szrj _List_profile(_List_profile&& __other) noexcept 81*38fd1498Szrj : _List_profile() 82*38fd1498Szrj { _M_swap(__other); } 83*38fd1498Szrj 84*38fd1498Szrj _List_profile& 85*38fd1498Szrj operator=(const _List_profile&) noexcept 86*38fd1498Szrj { 87*38fd1498Szrj _M_profile_destruct(); 88*38fd1498Szrj _M_profile_construct(); 89*38fd1498Szrj } 90*38fd1498Szrj 91*38fd1498Szrj _List_profile& 92*38fd1498Szrj operator=(_List_profile&& __other) noexcept 93*38fd1498Szrj { 94*38fd1498Szrj _M_swap(__other); 95*38fd1498Szrj __other._M_profile_destruct(); 96*38fd1498Szrj __other._M_profile_construct(); 97*38fd1498Szrj } 98*38fd1498Szrj#endif 99*38fd1498Szrj 100*38fd1498Szrj ~_List_profile() 101*38fd1498Szrj { _M_profile_destruct(); } 102*38fd1498Szrj }; 103*38fd1498Szrj 104*38fd1498Szrj /** @brief List wrapper with performance instrumentation. */ 105*38fd1498Szrj template<typename _Tp, typename _Allocator = std::allocator<_Tp> > 106*38fd1498Szrj class list 107*38fd1498Szrj : public _GLIBCXX_STD_C::list<_Tp, _Allocator>, 108*38fd1498Szrj public _List_profile<list<_Tp, _Allocator> > 109*38fd1498Szrj { 110*38fd1498Szrj typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base; 111*38fd1498Szrj 112*38fd1498Szrj public: 113*38fd1498Szrj typedef typename _Base::reference reference; 114*38fd1498Szrj typedef typename _Base::const_reference const_reference; 115*38fd1498Szrj 116*38fd1498Szrj typedef __iterator_tracker<typename _Base::iterator, list> 117*38fd1498Szrj iterator; 118*38fd1498Szrj typedef __iterator_tracker<typename _Base::const_iterator, list> 119*38fd1498Szrj const_iterator; 120*38fd1498Szrj 121*38fd1498Szrj typedef typename _Base::size_type size_type; 122*38fd1498Szrj typedef typename _Base::difference_type difference_type; 123*38fd1498Szrj 124*38fd1498Szrj typedef _Tp value_type; 125*38fd1498Szrj typedef _Allocator allocator_type; 126*38fd1498Szrj typedef typename _Base::pointer pointer; 127*38fd1498Szrj typedef typename _Base::const_pointer const_pointer; 128*38fd1498Szrj typedef std::reverse_iterator<iterator> reverse_iterator; 129*38fd1498Szrj typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 130*38fd1498Szrj 131*38fd1498Szrj // 23.2.2.1 construct/copy/destroy: 132*38fd1498Szrj 133*38fd1498Szrj#if __cplusplus < 201103L 134*38fd1498Szrj list() { } 135*38fd1498Szrj list(const list& __x) 136*38fd1498Szrj : _Base(__x) { } 137*38fd1498Szrj 138*38fd1498Szrj ~list() { } 139*38fd1498Szrj#else 140*38fd1498Szrj list() = default; 141*38fd1498Szrj list(const list&) = default; 142*38fd1498Szrj list(list&&) = default; 143*38fd1498Szrj ~list() = default; 144*38fd1498Szrj 145*38fd1498Szrj list(initializer_list<value_type> __l, 146*38fd1498Szrj const allocator_type& __a = allocator_type()) 147*38fd1498Szrj : _Base(__l, __a) { } 148*38fd1498Szrj 149*38fd1498Szrj list(const list& __x, const allocator_type& __a) 150*38fd1498Szrj : _Base(__x, __a) { } 151*38fd1498Szrj 152*38fd1498Szrj list(list&& __x, const allocator_type& __a) 153*38fd1498Szrj : _Base(std::move(__x), __a) { } 154*38fd1498Szrj#endif 155*38fd1498Szrj 156*38fd1498Szrj explicit 157*38fd1498Szrj list(const _Allocator& __a) _GLIBCXX_NOEXCEPT 158*38fd1498Szrj : _Base(__a) { } 159*38fd1498Szrj 160*38fd1498Szrj#if __cplusplus >= 201103L 161*38fd1498Szrj explicit 162*38fd1498Szrj list(size_type __n, const allocator_type& __a = allocator_type()) 163*38fd1498Szrj : _Base(__n, __a) { } 164*38fd1498Szrj 165*38fd1498Szrj list(size_type __n, const _Tp& __value, 166*38fd1498Szrj const _Allocator& __a = _Allocator()) 167*38fd1498Szrj : _Base(__n, __value, __a) { } 168*38fd1498Szrj#else 169*38fd1498Szrj explicit 170*38fd1498Szrj list(size_type __n, const _Tp& __value = _Tp(), 171*38fd1498Szrj const _Allocator& __a = _Allocator()) 172*38fd1498Szrj : _Base(__n, __value, __a) { } 173*38fd1498Szrj#endif 174*38fd1498Szrj 175*38fd1498Szrj#if __cplusplus >= 201103L 176*38fd1498Szrj template<typename _InputIterator, 177*38fd1498Szrj typename = std::_RequireInputIter<_InputIterator>> 178*38fd1498Szrj#else 179*38fd1498Szrj template<class _InputIterator> 180*38fd1498Szrj#endif 181*38fd1498Szrj list(_InputIterator __first, _InputIterator __last, 182*38fd1498Szrj const _Allocator& __a = _Allocator()) 183*38fd1498Szrj : _Base(__first, __last, __a) { } 184*38fd1498Szrj 185*38fd1498Szrj list(const _Base& __x) 186*38fd1498Szrj : _Base(__x) { } 187*38fd1498Szrj 188*38fd1498Szrj#if __cplusplus < 201103L 189*38fd1498Szrj list& 190*38fd1498Szrj operator=(const list& __x) 191*38fd1498Szrj { 192*38fd1498Szrj this->_M_profile_destruct(); 193*38fd1498Szrj _M_base() = __x; 194*38fd1498Szrj this->_M_profile_construct(); 195*38fd1498Szrj return *this; 196*38fd1498Szrj } 197*38fd1498Szrj#else 198*38fd1498Szrj list& 199*38fd1498Szrj operator=(const list&) = default; 200*38fd1498Szrj 201*38fd1498Szrj list& 202*38fd1498Szrj operator=(list&&) = default; 203*38fd1498Szrj 204*38fd1498Szrj list& 205*38fd1498Szrj operator=(initializer_list<value_type> __l) 206*38fd1498Szrj { 207*38fd1498Szrj this->_M_profile_destruct(); 208*38fd1498Szrj _M_base() = __l; 209*38fd1498Szrj this->_M_profile_construct(); 210*38fd1498Szrj return *this; 211*38fd1498Szrj } 212*38fd1498Szrj#endif 213*38fd1498Szrj 214*38fd1498Szrj // iterators: 215*38fd1498Szrj iterator 216*38fd1498Szrj begin() _GLIBCXX_NOEXCEPT 217*38fd1498Szrj { return iterator(_Base::begin(), this); } 218*38fd1498Szrj 219*38fd1498Szrj const_iterator 220*38fd1498Szrj begin() const _GLIBCXX_NOEXCEPT 221*38fd1498Szrj { return const_iterator(_Base::begin(), this); } 222*38fd1498Szrj 223*38fd1498Szrj iterator 224*38fd1498Szrj end() _GLIBCXX_NOEXCEPT 225*38fd1498Szrj { 226*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 227*38fd1498Szrj return iterator(_Base::end(), this); 228*38fd1498Szrj } 229*38fd1498Szrj 230*38fd1498Szrj const_iterator 231*38fd1498Szrj end() const _GLIBCXX_NOEXCEPT 232*38fd1498Szrj { 233*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 234*38fd1498Szrj return const_iterator(_Base::end(), this); 235*38fd1498Szrj } 236*38fd1498Szrj 237*38fd1498Szrj reverse_iterator 238*38fd1498Szrj rbegin() _GLIBCXX_NOEXCEPT 239*38fd1498Szrj { 240*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 241*38fd1498Szrj return reverse_iterator(end()); 242*38fd1498Szrj } 243*38fd1498Szrj 244*38fd1498Szrj const_reverse_iterator 245*38fd1498Szrj rbegin() const _GLIBCXX_NOEXCEPT 246*38fd1498Szrj { 247*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 248*38fd1498Szrj return const_reverse_iterator(end()); 249*38fd1498Szrj } 250*38fd1498Szrj 251*38fd1498Szrj reverse_iterator 252*38fd1498Szrj rend() _GLIBCXX_NOEXCEPT 253*38fd1498Szrj { return reverse_iterator(begin()); } 254*38fd1498Szrj 255*38fd1498Szrj const_reverse_iterator 256*38fd1498Szrj rend() const _GLIBCXX_NOEXCEPT 257*38fd1498Szrj { return const_reverse_iterator(begin()); } 258*38fd1498Szrj 259*38fd1498Szrj#if __cplusplus >= 201103L 260*38fd1498Szrj const_iterator 261*38fd1498Szrj cbegin() const noexcept 262*38fd1498Szrj { return const_iterator(_Base::cbegin(), this); } 263*38fd1498Szrj 264*38fd1498Szrj const_iterator 265*38fd1498Szrj cend() const noexcept 266*38fd1498Szrj { return const_iterator(_Base::cend(), this); } 267*38fd1498Szrj 268*38fd1498Szrj const_reverse_iterator 269*38fd1498Szrj crbegin() const noexcept 270*38fd1498Szrj { return const_reverse_iterator(end()); } 271*38fd1498Szrj 272*38fd1498Szrj const_reverse_iterator 273*38fd1498Szrj crend() const noexcept 274*38fd1498Szrj { return const_reverse_iterator(begin()); } 275*38fd1498Szrj#endif 276*38fd1498Szrj 277*38fd1498Szrj // 23.2.2.2 capacity: 278*38fd1498Szrj reference 279*38fd1498Szrj back() _GLIBCXX_NOEXCEPT 280*38fd1498Szrj { 281*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 282*38fd1498Szrj return _Base::back(); 283*38fd1498Szrj } 284*38fd1498Szrj 285*38fd1498Szrj const_reference 286*38fd1498Szrj back() const _GLIBCXX_NOEXCEPT 287*38fd1498Szrj { 288*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 289*38fd1498Szrj return _Base::back(); 290*38fd1498Szrj } 291*38fd1498Szrj 292*38fd1498Szrj // 23.2.2.3 modifiers: 293*38fd1498Szrj void 294*38fd1498Szrj push_front(const value_type& __x) 295*38fd1498Szrj { 296*38fd1498Szrj __profcxx_list2vector_invalid_operator(this->_M_list2vector_info); 297*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 298*38fd1498Szrj _Base::push_front(__x); 299*38fd1498Szrj } 300*38fd1498Szrj 301*38fd1498Szrj void 302*38fd1498Szrj pop_front() _GLIBCXX_NOEXCEPT 303*38fd1498Szrj { 304*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 305*38fd1498Szrj _Base::pop_front(); 306*38fd1498Szrj } 307*38fd1498Szrj 308*38fd1498Szrj void 309*38fd1498Szrj pop_back() _GLIBCXX_NOEXCEPT 310*38fd1498Szrj { 311*38fd1498Szrj _Base::pop_back(); 312*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 313*38fd1498Szrj } 314*38fd1498Szrj 315*38fd1498Szrj#if __cplusplus >= 201103L 316*38fd1498Szrj template<typename... _Args> 317*38fd1498Szrj iterator 318*38fd1498Szrj emplace(const_iterator __position, _Args&&... __args) 319*38fd1498Szrj { 320*38fd1498Szrj return iterator(_Base::emplace(__position.base(), 321*38fd1498Szrj std::forward<_Args>(__args)...), 322*38fd1498Szrj this); 323*38fd1498Szrj } 324*38fd1498Szrj#endif 325*38fd1498Szrj 326*38fd1498Szrj iterator 327*38fd1498Szrj#if __cplusplus >= 201103L 328*38fd1498Szrj insert(const_iterator __pos, const _Tp& __x) 329*38fd1498Szrj#else 330*38fd1498Szrj insert(iterator __pos, const _Tp& __x) 331*38fd1498Szrj#endif 332*38fd1498Szrj { 333*38fd1498Szrj _M_profile_insert(__pos, this->size()); 334*38fd1498Szrj return iterator(_Base::insert(__pos.base(), __x), this); 335*38fd1498Szrj } 336*38fd1498Szrj 337*38fd1498Szrj#if __cplusplus >= 201103L 338*38fd1498Szrj iterator 339*38fd1498Szrj insert(const_iterator __pos, _Tp&& __x) 340*38fd1498Szrj { 341*38fd1498Szrj _M_profile_insert(__pos, this->size()); 342*38fd1498Szrj return iterator(_Base::emplace(__pos.base(), std::move(__x)), 343*38fd1498Szrj this); 344*38fd1498Szrj } 345*38fd1498Szrj 346*38fd1498Szrj iterator 347*38fd1498Szrj insert(const_iterator __pos, initializer_list<value_type> __l) 348*38fd1498Szrj { 349*38fd1498Szrj _M_profile_insert(__pos, this->size()); 350*38fd1498Szrj return iterator(_Base::insert(__pos.base(), __l), this); 351*38fd1498Szrj } 352*38fd1498Szrj#endif 353*38fd1498Szrj 354*38fd1498Szrj#if __cplusplus >= 201103L 355*38fd1498Szrj iterator 356*38fd1498Szrj insert(const_iterator __pos, size_type __n, const _Tp& __x) 357*38fd1498Szrj { 358*38fd1498Szrj _M_profile_insert(__pos, this->size()); 359*38fd1498Szrj return iterator(_Base::insert(__pos.base(), __n, __x), this); 360*38fd1498Szrj } 361*38fd1498Szrj#else 362*38fd1498Szrj void 363*38fd1498Szrj insert(iterator __pos, size_type __n, const _Tp& __x) 364*38fd1498Szrj { 365*38fd1498Szrj _M_profile_insert(__pos, this->size()); 366*38fd1498Szrj _Base::insert(__pos.base(), __n, __x); 367*38fd1498Szrj } 368*38fd1498Szrj#endif 369*38fd1498Szrj 370*38fd1498Szrj#if __cplusplus >= 201103L 371*38fd1498Szrj template<typename _InputIterator, 372*38fd1498Szrj typename = std::_RequireInputIter<_InputIterator>> 373*38fd1498Szrj iterator 374*38fd1498Szrj insert(const_iterator __pos, _InputIterator __first, 375*38fd1498Szrj _InputIterator __last) 376*38fd1498Szrj { 377*38fd1498Szrj _M_profile_insert(__pos, this->size()); 378*38fd1498Szrj return iterator(_Base::insert(__pos.base(), __first, __last), 379*38fd1498Szrj this); 380*38fd1498Szrj } 381*38fd1498Szrj#else 382*38fd1498Szrj template<class _InputIterator> 383*38fd1498Szrj void 384*38fd1498Szrj insert(iterator __pos, _InputIterator __first, 385*38fd1498Szrj _InputIterator __last) 386*38fd1498Szrj { 387*38fd1498Szrj _M_profile_insert(__pos, this->size()); 388*38fd1498Szrj _Base::insert(__pos.base(), __first, __last); 389*38fd1498Szrj } 390*38fd1498Szrj#endif 391*38fd1498Szrj 392*38fd1498Szrj iterator 393*38fd1498Szrj#if __cplusplus >= 201103L 394*38fd1498Szrj erase(const_iterator __pos) noexcept 395*38fd1498Szrj#else 396*38fd1498Szrj erase(iterator __pos) 397*38fd1498Szrj#endif 398*38fd1498Szrj { return iterator(_Base::erase(__pos.base()), this); } 399*38fd1498Szrj 400*38fd1498Szrj iterator 401*38fd1498Szrj#if __cplusplus >= 201103L 402*38fd1498Szrj erase(const_iterator __pos, const_iterator __last) noexcept 403*38fd1498Szrj#else 404*38fd1498Szrj erase(iterator __pos, iterator __last) 405*38fd1498Szrj#endif 406*38fd1498Szrj { 407*38fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 408*38fd1498Szrj // 151. can't currently clear() empty container 409*38fd1498Szrj return iterator(_Base::erase(__pos.base(), __last.base()), this); 410*38fd1498Szrj } 411*38fd1498Szrj 412*38fd1498Szrj void 413*38fd1498Szrj swap(list& __x) 414*38fd1498Szrj _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) 415*38fd1498Szrj { 416*38fd1498Szrj _Base::swap(__x); 417*38fd1498Szrj this->_M_swap(__x); 418*38fd1498Szrj } 419*38fd1498Szrj 420*38fd1498Szrj void 421*38fd1498Szrj clear() _GLIBCXX_NOEXCEPT 422*38fd1498Szrj { 423*38fd1498Szrj this->_M_profile_destruct(); 424*38fd1498Szrj _Base::clear(); 425*38fd1498Szrj this->_M_profile_construct(); 426*38fd1498Szrj } 427*38fd1498Szrj 428*38fd1498Szrj // 23.2.2.4 list operations: 429*38fd1498Szrj void 430*38fd1498Szrj#if __cplusplus >= 201103L 431*38fd1498Szrj splice(const_iterator __pos, list&& __x) noexcept 432*38fd1498Szrj#else 433*38fd1498Szrj splice(iterator __pos, list& __x) 434*38fd1498Szrj#endif 435*38fd1498Szrj { this->splice(__pos, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); } 436*38fd1498Szrj 437*38fd1498Szrj#if __cplusplus >= 201103L 438*38fd1498Szrj void 439*38fd1498Szrj splice(const_iterator __pos, list& __x) noexcept 440*38fd1498Szrj { this->splice(__pos, std::move(__x)); } 441*38fd1498Szrj 442*38fd1498Szrj void 443*38fd1498Szrj splice(const_iterator __pos, list& __x, const_iterator __i) 444*38fd1498Szrj { this->splice(__pos, std::move(__x), __i); } 445*38fd1498Szrj#endif 446*38fd1498Szrj 447*38fd1498Szrj void 448*38fd1498Szrj#if __cplusplus >= 201103L 449*38fd1498Szrj splice(const_iterator __pos, list&& __x, const_iterator __i) noexcept 450*38fd1498Szrj#else 451*38fd1498Szrj splice(iterator __pos, list& __x, iterator __i) 452*38fd1498Szrj#endif 453*38fd1498Szrj { 454*38fd1498Szrj // We used to perform the splice_alloc check: not anymore, redundant 455*38fd1498Szrj // after implementing the relevant bits of N1599. 456*38fd1498Szrj 457*38fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 458*38fd1498Szrj _Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()), 459*38fd1498Szrj __i.base()); 460*38fd1498Szrj } 461*38fd1498Szrj 462*38fd1498Szrj void 463*38fd1498Szrj#if __cplusplus >= 201103L 464*38fd1498Szrj splice(const_iterator __pos, list&& __x, const_iterator __first, 465*38fd1498Szrj const_iterator __last) noexcept 466*38fd1498Szrj#else 467*38fd1498Szrj splice(iterator __pos, list& __x, iterator __first, 468*38fd1498Szrj iterator __last) 469*38fd1498Szrj#endif 470*38fd1498Szrj { 471*38fd1498Szrj _Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()), 472*38fd1498Szrj __first.base(), __last.base()); 473*38fd1498Szrj } 474*38fd1498Szrj 475*38fd1498Szrj#if __cplusplus >= 201103L 476*38fd1498Szrj void 477*38fd1498Szrj splice(const_iterator __pos, list& __x, 478*38fd1498Szrj const_iterator __first, const_iterator __last) noexcept 479*38fd1498Szrj { this->splice(__pos, std::move(__x), __first, __last); } 480*38fd1498Szrj#endif 481*38fd1498Szrj 482*38fd1498Szrj void 483*38fd1498Szrj remove(const _Tp& __value) 484*38fd1498Szrj { 485*38fd1498Szrj for (iterator __x = begin(); __x != end(); ) 486*38fd1498Szrj { 487*38fd1498Szrj if (*__x == __value) 488*38fd1498Szrj __x = erase(__x); 489*38fd1498Szrj else 490*38fd1498Szrj ++__x; 491*38fd1498Szrj } 492*38fd1498Szrj } 493*38fd1498Szrj 494*38fd1498Szrj template<class _Predicate> 495*38fd1498Szrj void 496*38fd1498Szrj remove_if(_Predicate __pred) 497*38fd1498Szrj { 498*38fd1498Szrj for (iterator __x = begin(); __x != end(); ) 499*38fd1498Szrj { 500*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 501*38fd1498Szrj if (__pred(*__x)) 502*38fd1498Szrj __x = erase(__x); 503*38fd1498Szrj else 504*38fd1498Szrj ++__x; 505*38fd1498Szrj } 506*38fd1498Szrj } 507*38fd1498Szrj 508*38fd1498Szrj void 509*38fd1498Szrj unique() 510*38fd1498Szrj { 511*38fd1498Szrj iterator __first = begin(); 512*38fd1498Szrj iterator __last = end(); 513*38fd1498Szrj if (__first == __last) 514*38fd1498Szrj return; 515*38fd1498Szrj iterator __next = __first; 516*38fd1498Szrj while (++__next != __last) 517*38fd1498Szrj { 518*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 519*38fd1498Szrj if (*__first == *__next) 520*38fd1498Szrj erase(__next); 521*38fd1498Szrj else 522*38fd1498Szrj __first = __next; 523*38fd1498Szrj __next = __first; 524*38fd1498Szrj } 525*38fd1498Szrj } 526*38fd1498Szrj 527*38fd1498Szrj template<class _BinaryPredicate> 528*38fd1498Szrj void 529*38fd1498Szrj unique(_BinaryPredicate __binary_pred) 530*38fd1498Szrj { 531*38fd1498Szrj iterator __first = begin(); 532*38fd1498Szrj iterator __last = end(); 533*38fd1498Szrj if (__first == __last) 534*38fd1498Szrj return; 535*38fd1498Szrj iterator __next = __first; 536*38fd1498Szrj while (++__next != __last) 537*38fd1498Szrj { 538*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 539*38fd1498Szrj if (__binary_pred(*__first, *__next)) 540*38fd1498Szrj erase(__next); 541*38fd1498Szrj else 542*38fd1498Szrj __first = __next; 543*38fd1498Szrj __next = __first; 544*38fd1498Szrj } 545*38fd1498Szrj } 546*38fd1498Szrj 547*38fd1498Szrj void 548*38fd1498Szrj#if __cplusplus >= 201103L 549*38fd1498Szrj merge(list&& __x) 550*38fd1498Szrj#else 551*38fd1498Szrj merge(list& __x) 552*38fd1498Szrj#endif 553*38fd1498Szrj { _Base::merge(_GLIBCXX_MOVE(__x._M_base())); } 554*38fd1498Szrj 555*38fd1498Szrj#if __cplusplus >= 201103L 556*38fd1498Szrj void 557*38fd1498Szrj merge(list& __x) 558*38fd1498Szrj { this->merge(std::move(__x)); } 559*38fd1498Szrj#endif 560*38fd1498Szrj 561*38fd1498Szrj template<class _Compare> 562*38fd1498Szrj void 563*38fd1498Szrj#if __cplusplus >= 201103L 564*38fd1498Szrj merge(list&& __x, _Compare __comp) 565*38fd1498Szrj#else 566*38fd1498Szrj merge(list& __x, _Compare __comp) 567*38fd1498Szrj#endif 568*38fd1498Szrj { _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); } 569*38fd1498Szrj 570*38fd1498Szrj#if __cplusplus >= 201103L 571*38fd1498Szrj template<typename _Compare> 572*38fd1498Szrj void 573*38fd1498Szrj merge(list& __x, _Compare __comp) 574*38fd1498Szrj { this->merge(std::move(__x), __comp); } 575*38fd1498Szrj#endif 576*38fd1498Szrj 577*38fd1498Szrj _Base& 578*38fd1498Szrj _M_base() _GLIBCXX_NOEXCEPT { return *this; } 579*38fd1498Szrj 580*38fd1498Szrj const _Base& 581*38fd1498Szrj _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 582*38fd1498Szrj 583*38fd1498Szrj void _M_profile_iterate(int __rewind = 0) const 584*38fd1498Szrj { 585*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 586*38fd1498Szrj __profcxx_list2vector_iterate(this->_M_list2vector_info, __rewind); 587*38fd1498Szrj if (__rewind) 588*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 589*38fd1498Szrj } 590*38fd1498Szrj 591*38fd1498Szrj private: 592*38fd1498Szrj size_type 593*38fd1498Szrj _M_profile_insert(const_iterator __pos, size_type __size) 594*38fd1498Szrj { 595*38fd1498Szrj size_type __shift = 0; 596*38fd1498Szrj typename _Base::const_iterator __it = __pos.base(); 597*38fd1498Szrj for (; __it != _Base::end(); ++__it) 598*38fd1498Szrj __shift++; 599*38fd1498Szrj __profcxx_list2slist_rewind(this->_M_list2slist_info); 600*38fd1498Szrj __profcxx_list2slist_operation(this->_M_list2slist_info); 601*38fd1498Szrj __profcxx_list2vector_insert(this->_M_list2vector_info, __shift, __size); 602*38fd1498Szrj } 603*38fd1498Szrj }; 604*38fd1498Szrj 605*38fd1498Szrj template<typename _Tp, typename _Alloc> 606*38fd1498Szrj inline bool 607*38fd1498Szrj operator==(const list<_Tp, _Alloc>& __lhs, 608*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 609*38fd1498Szrj { return __lhs._M_base() == __rhs._M_base(); } 610*38fd1498Szrj 611*38fd1498Szrj template<typename _Tp, typename _Alloc> 612*38fd1498Szrj inline bool 613*38fd1498Szrj operator!=(const list<_Tp, _Alloc>& __lhs, 614*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 615*38fd1498Szrj { return __lhs._M_base() != __rhs._M_base(); } 616*38fd1498Szrj 617*38fd1498Szrj template<typename _Tp, typename _Alloc> 618*38fd1498Szrj inline bool 619*38fd1498Szrj operator<(const list<_Tp, _Alloc>& __lhs, 620*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 621*38fd1498Szrj { return __lhs._M_base() < __rhs._M_base(); } 622*38fd1498Szrj 623*38fd1498Szrj template<typename _Tp, typename _Alloc> 624*38fd1498Szrj inline bool 625*38fd1498Szrj operator<=(const list<_Tp, _Alloc>& __lhs, 626*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 627*38fd1498Szrj { return __lhs._M_base() <= __rhs._M_base(); } 628*38fd1498Szrj 629*38fd1498Szrj template<typename _Tp, typename _Alloc> 630*38fd1498Szrj inline bool 631*38fd1498Szrj operator>=(const list<_Tp, _Alloc>& __lhs, 632*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 633*38fd1498Szrj { return __lhs._M_base() >= __rhs._M_base(); } 634*38fd1498Szrj 635*38fd1498Szrj template<typename _Tp, typename _Alloc> 636*38fd1498Szrj inline bool 637*38fd1498Szrj operator>(const list<_Tp, _Alloc>& __lhs, 638*38fd1498Szrj const list<_Tp, _Alloc>& __rhs) 639*38fd1498Szrj { return __lhs._M_base() > __rhs._M_base(); } 640*38fd1498Szrj 641*38fd1498Szrj template<typename _Tp, typename _Alloc> 642*38fd1498Szrj inline void 643*38fd1498Szrj swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) 644*38fd1498Szrj _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) 645*38fd1498Szrj { __lhs.swap(__rhs); } 646*38fd1498Szrj 647*38fd1498Szrj} // namespace __profile 648*38fd1498Szrj} // namespace std 649*38fd1498Szrj 650*38fd1498Szrj#endif 651