libstdc++
forward_list
Go to the documentation of this file.
00001 // <forward_list> -*- C++ -*-
00002 
00003 // Copyright (C) 2010-2015 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       explicit
00055       forward_list(const _Alloc& __al = _Alloc())
00056       : _Base(__al) { }
00057 
00058       forward_list(const forward_list& __list, const _Alloc& __al)
00059       : _Base(__list, __al)
00060       { }
00061 
00062       forward_list(forward_list&& __list, const _Alloc& __al)
00063       : _Base(std::move(__list), __al)
00064       { }
00065 
00066       explicit
00067       forward_list(size_type __n, const _Alloc& __al = _Alloc())
00068       : _Base(__n, __al)
00069       { }
00070 
00071       forward_list(size_type __n, const _Tp& __value,
00072                    const _Alloc& __al = _Alloc())
00073       : _Base(__n, __value, __al)
00074       { }
00075 
00076       template<typename _InputIterator,
00077                typename = std::_RequireInputIter<_InputIterator>>
00078         forward_list(_InputIterator __first, _InputIterator __last,
00079                      const _Alloc& __al = _Alloc())
00080         : _Base(__first, __last, __al)
00081         { }
00082 
00083       forward_list(const forward_list&) = default;
00084       forward_list(forward_list&&) = default;
00085 
00086       forward_list(std::initializer_list<_Tp> __il,
00087                    const _Alloc& __al = _Alloc())
00088       : _Base(__il, __al)
00089       { }
00090 
00091       ~forward_list() = default;
00092 
00093       forward_list&
00094       operator=(const forward_list&) = default;
00095 
00096       forward_list&
00097       operator=(forward_list&&) = default;
00098 
00099       forward_list&
00100       operator=(std::initializer_list<_Tp> __il)
00101       {
00102         _M_base() = __il;
00103         return *this;
00104       }
00105 
00106       void
00107       swap(forward_list& __fl)
00108         noexcept( noexcept(declval<_Base>().swap(__fl)) )
00109       { _Base::swap(__fl); }
00110 
00111       void
00112       splice_after(const_iterator __pos, forward_list&& __fl)
00113       { _Base::splice_after(__pos, std::move(__fl)); }
00114 
00115       void
00116       splice_after(const_iterator __pos, forward_list& __list)
00117       { _Base::splice_after(__pos, __list); }
00118 
00119       void
00120       splice_after(const_iterator __pos, forward_list&& __list,
00121                    const_iterator __i)
00122       { _Base::splice_after(__pos, std::move(__list), __i); }
00123 
00124       void
00125       splice_after(const_iterator __pos, forward_list& __list,
00126                    const_iterator __i)
00127       { _Base::splice_after(__pos, __list, __i); }
00128 
00129       void
00130       splice_after(const_iterator __pos, forward_list&& __list,
00131                    const_iterator __before, const_iterator __last)
00132       { _Base::splice_after(__pos, std::move(__list), __before, __last); }
00133 
00134       void
00135       splice_after(const_iterator __pos, forward_list& __list,
00136                    const_iterator __before, const_iterator __last)
00137       { _Base::splice_after(__pos, __list, __before, __last); }
00138 
00139       void
00140       merge(forward_list&& __list)
00141       { _Base::merge(std::move(__list)); }
00142 
00143       void
00144       merge(forward_list& __list)
00145       { _Base::merge(__list); }
00146 
00147       template<typename _Comp>
00148         void
00149         merge(forward_list&& __list, _Comp __comp)
00150         { _Base::merge(std::move(__list), __comp); }
00151 
00152       template<typename _Comp>
00153         void
00154         merge(forward_list& __list, _Comp __comp)
00155         { _Base::merge(__list, __comp); }
00156 
00157       _Base&
00158       _M_base() noexcept        { return *this; }
00159 
00160       const _Base&
00161       _M_base() const noexcept  { return *this; }
00162     };
00163 
00164   template<typename _Tp, typename _Alloc>
00165     inline bool
00166     operator==(const forward_list<_Tp, _Alloc>& __lx,
00167                const forward_list<_Tp, _Alloc>& __ly)
00168     { return __lx._M_base() == __ly._M_base(); }
00169 
00170   template<typename _Tp, typename _Alloc>
00171     inline bool
00172     operator<(const forward_list<_Tp, _Alloc>& __lx,
00173               const forward_list<_Tp, _Alloc>& __ly)
00174     { return __lx._M_base() < __ly._M_base(); }
00175 
00176   template<typename _Tp, typename _Alloc>
00177     inline bool
00178     operator!=(const forward_list<_Tp, _Alloc>& __lx,
00179                const forward_list<_Tp, _Alloc>& __ly)
00180     { return !(__lx == __ly); }
00181 
00182   /// Based on operator<
00183   template<typename _Tp, typename _Alloc>
00184     inline bool
00185     operator>(const forward_list<_Tp, _Alloc>& __lx,
00186               const forward_list<_Tp, _Alloc>& __ly)
00187     { return (__ly < __lx); }
00188 
00189   /// Based on operator<
00190   template<typename _Tp, typename _Alloc>
00191     inline bool
00192     operator>=(const forward_list<_Tp, _Alloc>& __lx,
00193                const forward_list<_Tp, _Alloc>& __ly)
00194     { return !(__lx < __ly); }
00195 
00196   /// Based on operator<
00197   template<typename _Tp, typename _Alloc>
00198     inline bool
00199     operator<=(const forward_list<_Tp, _Alloc>& __lx,
00200                const forward_list<_Tp, _Alloc>& __ly)
00201     { return !(__ly < __lx); }
00202 
00203   /// See std::forward_list::swap().
00204   template<typename _Tp, typename _Alloc>
00205     inline void
00206     swap(forward_list<_Tp, _Alloc>& __lx,
00207          forward_list<_Tp, _Alloc>& __ly)
00208     { __lx.swap(__ly); }
00209 
00210 } // namespace __profile
00211 } // namespace std
00212 
00213 #endif // C++11
00214 
00215 #endif