libstdc++
forward_list
Go to the documentation of this file.
00001 // <forward_list> -*- C++ -*-
00002 
00003 // Copyright (C) 2010-2018 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file profile/forward_list
00026  *  This file is a GNU debug extension to the Standard C++ Library.
00027  */
00028 
00029 #ifndef _GLIBCXX_PROFILE_FORWARD_LIST
00030 #define _GLIBCXX_PROFILE_FORWARD_LIST 1
00031 
00032 #if __cplusplus < 201103L
00033 # include <bits/c++0x_warning.h>
00034 #else
00035 
00036 #include <forward_list>
00037 
00038 namespace std _GLIBCXX_VISIBILITY(default)
00039 {
00040 namespace __profile
00041 {
00042   /// Class std::forward_list wrapper with performance instrumentation.
00043   template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
00044     class forward_list
00045     : public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc>
00046     {
00047       typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
00048 
00049     public:
00050       typedef typename _Base::size_type         size_type;
00051       typedef typename _Base::const_iterator    const_iterator;
00052 
00053       // 23.2.3.1 construct/copy/destroy:
00054 
00055       forward_list() = default;
00056 
00057       explicit
00058       forward_list(const _Alloc& __al) noexcept
00059       : _Base(__al) { }
00060 
00061       forward_list(const forward_list& __list, const _Alloc& __al)
00062       : _Base(__list, __al)
00063       { }
00064 
00065       forward_list(forward_list&& __list, const _Alloc& __al)
00066       : _Base(std::move(__list), __al)
00067       { }
00068 
00069       explicit
00070       forward_list(size_type __n, const _Alloc& __al = _Alloc())
00071       : _Base(__n, __al)
00072       { }
00073 
00074       forward_list(size_type __n, const _Tp& __value,
00075                    const _Alloc& __al = _Alloc())
00076       : _Base(__n, __value, __al)
00077       { }
00078 
00079       template<typename _InputIterator,
00080                typename = std::_RequireInputIter<_InputIterator>>
00081         forward_list(_InputIterator __first, _InputIterator __last,
00082                      const _Alloc& __al = _Alloc())
00083         : _Base(__first, __last, __al)
00084         { }
00085 
00086       forward_list(const forward_list&) = default;
00087       forward_list(forward_list&&) = default;
00088 
00089       forward_list(std::initializer_list<_Tp> __il,
00090                    const _Alloc& __al = _Alloc())
00091       : _Base(__il, __al)
00092       { }
00093 
00094       ~forward_list() = default;
00095 
00096       forward_list&
00097       operator=(const forward_list&) = default;
00098 
00099       forward_list&
00100       operator=(forward_list&&) = default;
00101 
00102       forward_list&
00103       operator=(std::initializer_list<_Tp> __il)
00104       {
00105         _M_base() = __il;
00106         return *this;
00107       }
00108 
00109       void
00110       swap(forward_list& __fl)
00111         noexcept( noexcept(declval<_Base&>().swap(__fl)) )
00112       { _Base::swap(__fl); }
00113 
00114       void
00115       splice_after(const_iterator __pos, forward_list&& __fl)
00116       { _Base::splice_after(__pos, std::move(__fl)); }
00117 
00118       void
00119       splice_after(const_iterator __pos, forward_list& __list)
00120       { _Base::splice_after(__pos, __list); }
00121 
00122       void
00123       splice_after(const_iterator __pos, forward_list&& __list,
00124                    const_iterator __i)
00125       { _Base::splice_after(__pos, std::move(__list), __i); }
00126 
00127       void
00128       splice_after(const_iterator __pos, forward_list& __list,
00129                    const_iterator __i)
00130       { _Base::splice_after(__pos, __list, __i); }
00131 
00132       void
00133       splice_after(const_iterator __pos, forward_list&& __list,
00134                    const_iterator __before, const_iterator __last)
00135       { _Base::splice_after(__pos, std::move(__list), __before, __last); }
00136 
00137       void
00138       splice_after(const_iterator __pos, forward_list& __list,
00139                    const_iterator __before, const_iterator __last)
00140       { _Base::splice_after(__pos, __list, __before, __last); }
00141 
00142       void
00143       merge(forward_list&& __list)
00144       { _Base::merge(std::move(__list)); }
00145 
00146       void
00147       merge(forward_list& __list)
00148       { _Base::merge(__list); }
00149 
00150       template<typename _Comp>
00151         void
00152         merge(forward_list&& __list, _Comp __comp)
00153         { _Base::merge(std::move(__list), __comp); }
00154 
00155       template<typename _Comp>
00156         void
00157         merge(forward_list& __list, _Comp __comp)
00158         { _Base::merge(__list, __comp); }
00159 
00160       _Base&
00161       _M_base() noexcept        { return *this; }
00162 
00163       const _Base&
00164       _M_base() const noexcept  { return *this; }
00165     };
00166 
00167   template<typename _Tp, typename _Alloc>
00168     inline bool
00169     operator==(const forward_list<_Tp, _Alloc>& __lx,
00170                const forward_list<_Tp, _Alloc>& __ly)
00171     { return __lx._M_base() == __ly._M_base(); }
00172 
00173   template<typename _Tp, typename _Alloc>
00174     inline bool
00175     operator<(const forward_list<_Tp, _Alloc>& __lx,
00176               const forward_list<_Tp, _Alloc>& __ly)
00177     { return __lx._M_base() < __ly._M_base(); }
00178 
00179   template<typename _Tp, typename _Alloc>
00180     inline bool
00181     operator!=(const forward_list<_Tp, _Alloc>& __lx,
00182                const forward_list<_Tp, _Alloc>& __ly)
00183     { return !(__lx == __ly); }
00184 
00185   /// Based on operator<
00186   template<typename _Tp, typename _Alloc>
00187     inline bool
00188     operator>(const forward_list<_Tp, _Alloc>& __lx,
00189               const forward_list<_Tp, _Alloc>& __ly)
00190     { return (__ly < __lx); }
00191 
00192   /// Based on operator<
00193   template<typename _Tp, typename _Alloc>
00194     inline bool
00195     operator>=(const forward_list<_Tp, _Alloc>& __lx,
00196                const forward_list<_Tp, _Alloc>& __ly)
00197     { return !(__lx < __ly); }
00198 
00199   /// Based on operator<
00200   template<typename _Tp, typename _Alloc>
00201     inline bool
00202     operator<=(const forward_list<_Tp, _Alloc>& __lx,
00203                const forward_list<_Tp, _Alloc>& __ly)
00204     { return !(__ly < __lx); }
00205 
00206   /// See std::forward_list::swap().
00207   template<typename _Tp, typename _Alloc>
00208     inline void
00209     swap(forward_list<_Tp, _Alloc>& __lx,
00210          forward_list<_Tp, _Alloc>& __ly)
00211     noexcept(noexcept(__lx.swap(__ly)))
00212     { __lx.swap(__ly); }
00213 
00214 } // namespace __profile
00215 } // namespace std
00216 
00217 #endif // C++11
00218 
00219 #endif