1 // <forward_list> -*- C++ -*-
3 // Copyright (C) 2010-2019 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file profile/forward_list
26 * This file is a GNU debug extension to the Standard C++ Library.
29 #ifndef _GLIBCXX_PROFILE_FORWARD_LIST
30 #define _GLIBCXX_PROFILE_FORWARD_LIST 1
32 #if __cplusplus < 201103L
33 # include <bits/c++0x_warning.h>
36 #include <forward_list>
38 namespace std _GLIBCXX_VISIBILITY(default)
42 /// Class std::forward_list wrapper with performance instrumentation.
43 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
45 : public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc>
47 typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
50 typedef typename _Base::size_type size_type;
51 typedef typename _Base::const_iterator const_iterator;
53 // 23.2.3.1 construct/copy/destroy:
55 forward_list() = default;
58 forward_list(const _Alloc& __al) noexcept
61 forward_list(const forward_list& __list, const _Alloc& __al)
65 forward_list(forward_list&& __list, const _Alloc& __al)
66 : _Base(std::move(__list), __al)
70 forward_list(size_type __n, const _Alloc& __al = _Alloc())
74 forward_list(size_type __n, const _Tp& __value,
75 const _Alloc& __al = _Alloc())
76 : _Base(__n, __value, __al)
79 template<typename _InputIterator,
80 typename = std::_RequireInputIter<_InputIterator>>
81 forward_list(_InputIterator __first, _InputIterator __last,
82 const _Alloc& __al = _Alloc())
83 : _Base(__first, __last, __al)
86 forward_list(const forward_list&) = default;
87 forward_list(forward_list&&) = default;
89 forward_list(std::initializer_list<_Tp> __il,
90 const _Alloc& __al = _Alloc())
94 ~forward_list() = default;
97 operator=(const forward_list&) = default;
100 operator=(forward_list&&) = default;
103 operator=(std::initializer_list<_Tp> __il)
110 swap(forward_list& __fl)
111 noexcept( noexcept(declval<_Base&>().swap(__fl)) )
112 { _Base::swap(__fl); }
115 splice_after(const_iterator __pos, forward_list&& __fl)
116 { _Base::splice_after(__pos, std::move(__fl)); }
119 splice_after(const_iterator __pos, forward_list& __list)
120 { _Base::splice_after(__pos, __list); }
123 splice_after(const_iterator __pos, forward_list&& __list,
125 { _Base::splice_after(__pos, std::move(__list), __i); }
128 splice_after(const_iterator __pos, forward_list& __list,
130 { _Base::splice_after(__pos, __list, __i); }
133 splice_after(const_iterator __pos, forward_list&& __list,
134 const_iterator __before, const_iterator __last)
135 { _Base::splice_after(__pos, std::move(__list), __before, __last); }
138 splice_after(const_iterator __pos, forward_list& __list,
139 const_iterator __before, const_iterator __last)
140 { _Base::splice_after(__pos, __list, __before, __last); }
143 merge(forward_list&& __list)
144 { _Base::merge(std::move(__list)); }
147 merge(forward_list& __list)
148 { _Base::merge(__list); }
150 template<typename _Comp>
152 merge(forward_list&& __list, _Comp __comp)
153 { _Base::merge(std::move(__list), __comp); }
155 template<typename _Comp>
157 merge(forward_list& __list, _Comp __comp)
158 { _Base::merge(__list, __comp); }
161 _M_base() noexcept { return *this; }
164 _M_base() const noexcept { return *this; }
167 template<typename _Tp, typename _Alloc>
169 operator==(const forward_list<_Tp, _Alloc>& __lx,
170 const forward_list<_Tp, _Alloc>& __ly)
171 { return __lx._M_base() == __ly._M_base(); }
173 template<typename _Tp, typename _Alloc>
175 operator<(const forward_list<_Tp, _Alloc>& __lx,
176 const forward_list<_Tp, _Alloc>& __ly)
177 { return __lx._M_base() < __ly._M_base(); }
179 template<typename _Tp, typename _Alloc>
181 operator!=(const forward_list<_Tp, _Alloc>& __lx,
182 const forward_list<_Tp, _Alloc>& __ly)
183 { return !(__lx == __ly); }
185 /// Based on operator<
186 template<typename _Tp, typename _Alloc>
188 operator>(const forward_list<_Tp, _Alloc>& __lx,
189 const forward_list<_Tp, _Alloc>& __ly)
190 { return (__ly < __lx); }
192 /// Based on operator<
193 template<typename _Tp, typename _Alloc>
195 operator>=(const forward_list<_Tp, _Alloc>& __lx,
196 const forward_list<_Tp, _Alloc>& __ly)
197 { return !(__lx < __ly); }
199 /// Based on operator<
200 template<typename _Tp, typename _Alloc>
202 operator<=(const forward_list<_Tp, _Alloc>& __lx,
203 const forward_list<_Tp, _Alloc>& __ly)
204 { return !(__ly < __lx); }
206 /// See std::forward_list::swap().
207 template<typename _Tp, typename _Alloc>
209 swap(forward_list<_Tp, _Alloc>& __lx,
210 forward_list<_Tp, _Alloc>& __ly)
211 noexcept(noexcept(__lx.swap(__ly)))
214 } // namespace __profile