1*38fd1498Szrj// <forward_list> -*- C++ -*- 2*38fd1498Szrj 3*38fd1498Szrj// Copyright (C) 2010-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/forward_list 26*38fd1498Szrj * This file is a GNU debug extension to the Standard C++ Library. 27*38fd1498Szrj */ 28*38fd1498Szrj 29*38fd1498Szrj#ifndef _GLIBCXX_PROFILE_FORWARD_LIST 30*38fd1498Szrj#define _GLIBCXX_PROFILE_FORWARD_LIST 1 31*38fd1498Szrj 32*38fd1498Szrj#if __cplusplus < 201103L 33*38fd1498Szrj# include <bits/c++0x_warning.h> 34*38fd1498Szrj#else 35*38fd1498Szrj 36*38fd1498Szrj#include <forward_list> 37*38fd1498Szrj 38*38fd1498Szrjnamespace std _GLIBCXX_VISIBILITY(default) 39*38fd1498Szrj{ 40*38fd1498Szrjnamespace __profile 41*38fd1498Szrj{ 42*38fd1498Szrj /// Class std::forward_list wrapper with performance instrumentation. 43*38fd1498Szrj template<typename _Tp, typename _Alloc = std::allocator<_Tp> > 44*38fd1498Szrj class forward_list 45*38fd1498Szrj : public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> 46*38fd1498Szrj { 47*38fd1498Szrj typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base; 48*38fd1498Szrj 49*38fd1498Szrj public: 50*38fd1498Szrj typedef typename _Base::size_type size_type; 51*38fd1498Szrj typedef typename _Base::const_iterator const_iterator; 52*38fd1498Szrj 53*38fd1498Szrj // 23.2.3.1 construct/copy/destroy: 54*38fd1498Szrj 55*38fd1498Szrj forward_list() = default; 56*38fd1498Szrj 57*38fd1498Szrj explicit 58*38fd1498Szrj forward_list(const _Alloc& __al) noexcept 59*38fd1498Szrj : _Base(__al) { } 60*38fd1498Szrj 61*38fd1498Szrj forward_list(const forward_list& __list, const _Alloc& __al) 62*38fd1498Szrj : _Base(__list, __al) 63*38fd1498Szrj { } 64*38fd1498Szrj 65*38fd1498Szrj forward_list(forward_list&& __list, const _Alloc& __al) 66*38fd1498Szrj : _Base(std::move(__list), __al) 67*38fd1498Szrj { } 68*38fd1498Szrj 69*38fd1498Szrj explicit 70*38fd1498Szrj forward_list(size_type __n, const _Alloc& __al = _Alloc()) 71*38fd1498Szrj : _Base(__n, __al) 72*38fd1498Szrj { } 73*38fd1498Szrj 74*38fd1498Szrj forward_list(size_type __n, const _Tp& __value, 75*38fd1498Szrj const _Alloc& __al = _Alloc()) 76*38fd1498Szrj : _Base(__n, __value, __al) 77*38fd1498Szrj { } 78*38fd1498Szrj 79*38fd1498Szrj template<typename _InputIterator, 80*38fd1498Szrj typename = std::_RequireInputIter<_InputIterator>> 81*38fd1498Szrj forward_list(_InputIterator __first, _InputIterator __last, 82*38fd1498Szrj const _Alloc& __al = _Alloc()) 83*38fd1498Szrj : _Base(__first, __last, __al) 84*38fd1498Szrj { } 85*38fd1498Szrj 86*38fd1498Szrj forward_list(const forward_list&) = default; 87*38fd1498Szrj forward_list(forward_list&&) = default; 88*38fd1498Szrj 89*38fd1498Szrj forward_list(std::initializer_list<_Tp> __il, 90*38fd1498Szrj const _Alloc& __al = _Alloc()) 91*38fd1498Szrj : _Base(__il, __al) 92*38fd1498Szrj { } 93*38fd1498Szrj 94*38fd1498Szrj ~forward_list() = default; 95*38fd1498Szrj 96*38fd1498Szrj forward_list& 97*38fd1498Szrj operator=(const forward_list&) = default; 98*38fd1498Szrj 99*38fd1498Szrj forward_list& 100*38fd1498Szrj operator=(forward_list&&) = default; 101*38fd1498Szrj 102*38fd1498Szrj forward_list& 103*38fd1498Szrj operator=(std::initializer_list<_Tp> __il) 104*38fd1498Szrj { 105*38fd1498Szrj _M_base() = __il; 106*38fd1498Szrj return *this; 107*38fd1498Szrj } 108*38fd1498Szrj 109*38fd1498Szrj void 110*38fd1498Szrj swap(forward_list& __fl) 111*38fd1498Szrj noexcept( noexcept(declval<_Base&>().swap(__fl)) ) 112*38fd1498Szrj { _Base::swap(__fl); } 113*38fd1498Szrj 114*38fd1498Szrj void 115*38fd1498Szrj splice_after(const_iterator __pos, forward_list&& __fl) 116*38fd1498Szrj { _Base::splice_after(__pos, std::move(__fl)); } 117*38fd1498Szrj 118*38fd1498Szrj void 119*38fd1498Szrj splice_after(const_iterator __pos, forward_list& __list) 120*38fd1498Szrj { _Base::splice_after(__pos, __list); } 121*38fd1498Szrj 122*38fd1498Szrj void 123*38fd1498Szrj splice_after(const_iterator __pos, forward_list&& __list, 124*38fd1498Szrj const_iterator __i) 125*38fd1498Szrj { _Base::splice_after(__pos, std::move(__list), __i); } 126*38fd1498Szrj 127*38fd1498Szrj void 128*38fd1498Szrj splice_after(const_iterator __pos, forward_list& __list, 129*38fd1498Szrj const_iterator __i) 130*38fd1498Szrj { _Base::splice_after(__pos, __list, __i); } 131*38fd1498Szrj 132*38fd1498Szrj void 133*38fd1498Szrj splice_after(const_iterator __pos, forward_list&& __list, 134*38fd1498Szrj const_iterator __before, const_iterator __last) 135*38fd1498Szrj { _Base::splice_after(__pos, std::move(__list), __before, __last); } 136*38fd1498Szrj 137*38fd1498Szrj void 138*38fd1498Szrj splice_after(const_iterator __pos, forward_list& __list, 139*38fd1498Szrj const_iterator __before, const_iterator __last) 140*38fd1498Szrj { _Base::splice_after(__pos, __list, __before, __last); } 141*38fd1498Szrj 142*38fd1498Szrj void 143*38fd1498Szrj merge(forward_list&& __list) 144*38fd1498Szrj { _Base::merge(std::move(__list)); } 145*38fd1498Szrj 146*38fd1498Szrj void 147*38fd1498Szrj merge(forward_list& __list) 148*38fd1498Szrj { _Base::merge(__list); } 149*38fd1498Szrj 150*38fd1498Szrj template<typename _Comp> 151*38fd1498Szrj void 152*38fd1498Szrj merge(forward_list&& __list, _Comp __comp) 153*38fd1498Szrj { _Base::merge(std::move(__list), __comp); } 154*38fd1498Szrj 155*38fd1498Szrj template<typename _Comp> 156*38fd1498Szrj void 157*38fd1498Szrj merge(forward_list& __list, _Comp __comp) 158*38fd1498Szrj { _Base::merge(__list, __comp); } 159*38fd1498Szrj 160*38fd1498Szrj _Base& 161*38fd1498Szrj _M_base() noexcept { return *this; } 162*38fd1498Szrj 163*38fd1498Szrj const _Base& 164*38fd1498Szrj _M_base() const noexcept { return *this; } 165*38fd1498Szrj }; 166*38fd1498Szrj 167*38fd1498Szrj template<typename _Tp, typename _Alloc> 168*38fd1498Szrj inline bool 169*38fd1498Szrj operator==(const forward_list<_Tp, _Alloc>& __lx, 170*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 171*38fd1498Szrj { return __lx._M_base() == __ly._M_base(); } 172*38fd1498Szrj 173*38fd1498Szrj template<typename _Tp, typename _Alloc> 174*38fd1498Szrj inline bool 175*38fd1498Szrj operator<(const forward_list<_Tp, _Alloc>& __lx, 176*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 177*38fd1498Szrj { return __lx._M_base() < __ly._M_base(); } 178*38fd1498Szrj 179*38fd1498Szrj template<typename _Tp, typename _Alloc> 180*38fd1498Szrj inline bool 181*38fd1498Szrj operator!=(const forward_list<_Tp, _Alloc>& __lx, 182*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 183*38fd1498Szrj { return !(__lx == __ly); } 184*38fd1498Szrj 185*38fd1498Szrj /// Based on operator< 186*38fd1498Szrj template<typename _Tp, typename _Alloc> 187*38fd1498Szrj inline bool 188*38fd1498Szrj operator>(const forward_list<_Tp, _Alloc>& __lx, 189*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 190*38fd1498Szrj { return (__ly < __lx); } 191*38fd1498Szrj 192*38fd1498Szrj /// Based on operator< 193*38fd1498Szrj template<typename _Tp, typename _Alloc> 194*38fd1498Szrj inline bool 195*38fd1498Szrj operator>=(const forward_list<_Tp, _Alloc>& __lx, 196*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 197*38fd1498Szrj { return !(__lx < __ly); } 198*38fd1498Szrj 199*38fd1498Szrj /// Based on operator< 200*38fd1498Szrj template<typename _Tp, typename _Alloc> 201*38fd1498Szrj inline bool 202*38fd1498Szrj operator<=(const forward_list<_Tp, _Alloc>& __lx, 203*38fd1498Szrj const forward_list<_Tp, _Alloc>& __ly) 204*38fd1498Szrj { return !(__ly < __lx); } 205*38fd1498Szrj 206*38fd1498Szrj /// See std::forward_list::swap(). 207*38fd1498Szrj template<typename _Tp, typename _Alloc> 208*38fd1498Szrj inline void 209*38fd1498Szrj swap(forward_list<_Tp, _Alloc>& __lx, 210*38fd1498Szrj forward_list<_Tp, _Alloc>& __ly) 211*38fd1498Szrj noexcept(noexcept(__lx.swap(__ly))) 212*38fd1498Szrj { __lx.swap(__ly); } 213*38fd1498Szrj 214*38fd1498Szrj} // namespace __profile 215*38fd1498Szrj} // namespace std 216*38fd1498Szrj 217*38fd1498Szrj#endif // C++11 218*38fd1498Szrj 219*38fd1498Szrj#endif 220