55 #ifndef _GLIBCXX_UTILITY
56 #define _GLIBCXX_UTILITY 1
58 #pragma GCC system_header
72 #if __cplusplus >= 201103L
76 namespace std _GLIBCXX_VISIBILITY(default)
78 _GLIBCXX_BEGIN_NAMESPACE_VERSION
83 template<std::
size_t _Int,
class _Tp>
87 template<
class _Tp1,
class _Tp2>
88 struct tuple_size<std::pair<_Tp1, _Tp2>>
89 :
public integral_constant<std::size_t, 2> { };
91 template<
class _Tp1,
class _Tp2>
92 struct tuple_element<0, std::pair<_Tp1, _Tp2>>
93 {
typedef _Tp1 type; };
95 template<
class _Tp1,
class _Tp2>
96 struct tuple_element<1, std::pair<_Tp1, _Tp2>>
97 {
typedef _Tp2 type; };
99 template<std::
size_t _Int>
105 template<
typename _Tp1,
typename _Tp2>
106 static constexpr _Tp1&
108 {
return __pair.first; }
110 template<
typename _Tp1,
typename _Tp2>
111 static constexpr _Tp1&&
113 {
return std::forward<_Tp1>(__pair.first); }
115 template<
typename _Tp1,
typename _Tp2>
116 static constexpr
const _Tp1&
118 {
return __pair.first; }
124 template<
typename _Tp1,
typename _Tp2>
125 static constexpr _Tp2&
127 {
return __pair.second; }
129 template<
typename _Tp1,
typename _Tp2>
130 static constexpr _Tp2&&
132 {
return std::forward<_Tp2>(__pair.second); }
134 template<
typename _Tp1,
typename _Tp2>
135 static constexpr
const _Tp2&
137 {
return __pair.second; }
140 template<std::
size_t _Int,
class _Tp1,
class _Tp2>
141 constexpr
typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&
143 {
return __pair_get<_Int>::__get(__in); }
145 template<std::
size_t _Int,
class _Tp1,
class _Tp2>
146 constexpr
typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&&
148 {
return __pair_get<_Int>::__move_get(std::move(__in)); }
150 template<std::
size_t _Int,
class _Tp1,
class _Tp2>
151 constexpr
const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&
153 {
return __pair_get<_Int>::__const_get(__in); }
155 #if __cplusplus > 201103L
156 template <
typename _Tp,
typename _Up>
158 get(pair<_Tp, _Up>& __p) noexcept
159 {
return __p.first; }
161 template <
typename _Tp,
typename _Up>
163 get(
const pair<_Tp, _Up>& __p) noexcept
164 {
return __p.first; }
166 template <
typename _Tp,
typename _Up>
168 get(pair<_Tp, _Up>&& __p) noexcept
169 {
return std::move(__p.first); }
171 template <
typename _Tp,
typename _Up>
173 get(pair<_Up, _Tp>& __p) noexcept
174 {
return __p.second; }
176 template <
typename _Tp,
typename _Up>
178 get(
const pair<_Up, _Tp>& __p) noexcept
179 {
return __p.second; }
181 template <
typename _Tp,
typename _Up>
183 get(pair<_Up, _Tp>&& __p) noexcept
184 {
return std::move(__p.second); }
187 template <
typename _Tp,
typename _Up = _Tp>
189 exchange(_Tp& __obj, _Up&& __new_val)
191 _Tp __old_val = std::move(__obj);
192 __obj = std::forward<_Up>(__new_val);
199 template<
size_t... _Indexes>
202 typedef _Index_tuple<_Indexes...,
sizeof...(_Indexes)> __next;
206 template<
size_t _Num>
207 struct _Build_index_tuple
209 typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type;
213 struct _Build_index_tuple<0>
215 typedef _Index_tuple<> __type;
218 #if __cplusplus > 201103L
220 template<
typename _Tp, _Tp... _Idx>
221 struct integer_sequence
223 typedef _Tp value_type;
224 static constexpr
size_t size() {
return sizeof...(_Idx); }
227 template<
typename _Tp, _Tp _Num,
228 typename _ISeq =
typename _Build_index_tuple<_Num>::__type>
229 struct _Make_integer_sequence;
231 template<
typename _Tp, _Tp _Num,
size_t... _Idx>
232 struct _Make_integer_sequence<_Tp, _Num, _Index_tuple<_Idx...>>
234 static_assert( _Num >= 0,
235 "Cannot make integer sequence of negative length" );
237 typedef integer_sequence<_Tp, static_cast<_Tp>(_Idx)...> __type;
241 template<
typename _Tp, _Tp _Num>
242 using make_integer_sequence
243 =
typename _Make_integer_sequence<_Tp, _Num>::__type;
246 template<
size_t... _Idx>
247 using index_sequence = integer_sequence<size_t, _Idx...>;
250 template<
size_t _Num>
251 using make_index_sequence = make_integer_sequence<size_t, _Num>;
254 template<
typename... _Types>
255 using index_sequence_for = make_index_sequence<
sizeof...(_Types)>;
258 _GLIBCXX_END_NAMESPACE_VERSION
constexpr size_t size() const noexcept
Returns the total number of bits.
Struct holding two objects of arbitrary type.