33#ifndef _GLIBCXX_UTILITY_H
34#define _GLIBCXX_UTILITY_H 1
37#pragma GCC system_header
40#if __cplusplus >= 201103L
45namespace std _GLIBCXX_VISIBILITY(default)
47_GLIBCXX_BEGIN_NAMESPACE_VERSION
50 template<
typename _Tp>
57 template<
typename _Tp,
58 typename _Up =
typename remove_cv<_Tp>::type,
61 using __enable_if_has_tuple_size = _Tp;
63 template<
typename _Tp>
64 struct tuple_size<const __enable_if_has_tuple_size<_Tp>>
67 template<
typename _Tp>
68 struct tuple_size<volatile __enable_if_has_tuple_size<_Tp>>
71 template<
typename _Tp>
72 struct tuple_size<const volatile __enable_if_has_tuple_size<_Tp>>
73 :
public tuple_size<_Tp> { };
75#if __cplusplus >= 201703L
76 template<
typename _Tp>
81 template<
size_t __i,
typename _Tp>
85 template<
size_t __i,
typename _Tp>
88 template<
size_t __i,
typename _Tp>
91 using type =
const __tuple_element_t<__i, _Tp>;
94 template<
size_t __i,
typename _Tp>
97 using type =
volatile __tuple_element_t<__i, _Tp>;
100 template<
size_t __i,
typename _Tp>
101 struct tuple_element<__i, const volatile _Tp>
103 using type =
const volatile __tuple_element_t<__i, _Tp>;
106#if __cplusplus >= 201402L
110 template<
typename _Tp,
typename... _Types>
112 __find_uniq_type_in_pack()
114 constexpr size_t __sz =
sizeof...(_Types);
115 constexpr bool __found[__sz] = { __is_same(_Tp, _Types) ... };
117 for (
size_t __i = 0; __i < __sz; ++__i)
135#ifdef __glibcxx_tuple_element_t
136 template<
size_t __i,
typename _Tp>
140#ifdef __glibcxx_constant_wrapper
141 template<
typename _Tp>
147 _CwFixedValue(__type __v) noexcept
153 template<
typename _Tp,
size_t _Extent>
154 struct _CwFixedValue<_Tp[_Extent]>
156 using __type = _Tp[_Extent];
159 _CwFixedValue(_Tp (&__arr)[_Extent]) noexcept
160 : _CwFixedValue(__arr,
typename _Build_index_tuple<_Extent>::__type())
163 template<
size_t... _Indices>
165 _CwFixedValue(_Tp (&__arr)[_Extent], _Index_tuple<_Indices...>) noexcept
166 : _M_data{__arr[_Indices]...}
169 _Tp _M_data[_Extent];
172 template<
typename _Tp,
size_t _Extent>
173 _CwFixedValue(_Tp (&)[_Extent]) -> _CwFixedValue<_Tp[_Extent]>;
175 template<_CwFixedValue _Xv,
176 typename =
typename decltype(_CwFixedValue(_Xv))::__type>
177 struct constant_wrapper;
179 template<
typename _Tp>
180 concept _ConstExprParam =
requires
182 typename constant_wrapper<_Tp::value>;
187 template<_ConstExprParam _Tp>
188 friend constexpr auto
189 operator+(_Tp)
noexcept -> constant_wrapper<(+_Tp::value)>
192 template<_ConstExprParam _Tp>
193 friend constexpr auto
194 operator-(_Tp)
noexcept -> constant_wrapper<(-_Tp::value)>
197 template<_ConstExprParam _Tp>
198 friend constexpr auto
199 operator~(_Tp)
noexcept -> constant_wrapper<(~_Tp::value)>
202 template<_ConstExprParam _Tp>
203 friend constexpr auto
204 operator!(_Tp)
noexcept -> constant_wrapper<(!_Tp::value)>
207 template<_ConstExprParam _Tp>
208 friend constexpr auto
209 operator&(_Tp)
noexcept -> constant_wrapper<(&_Tp::value)>
212 template<_ConstExprParam _Tp>
213 friend constexpr auto
214 operator*(_Tp)
noexcept -> constant_wrapper<(*_Tp::value)>
217 template<_ConstExprParam _Left, _ConstExprParam _Right>
218 friend constexpr auto
220 -> constant_wrapper<(_Left::value + _Right::value)>
223 template<_ConstExprParam _Left, _ConstExprParam _Right>
224 friend constexpr auto
226 -> constant_wrapper<(_Left::value - _Right::value)>
229 template<_ConstExprParam _Left, _ConstExprParam _Right>
230 friend constexpr auto
232 -> constant_wrapper<(_Left::value * _Right::value)>
235 template<_ConstExprParam _Left, _ConstExprParam _Right>
236 friend constexpr auto
238 -> constant_wrapper<(_Left::value / _Right::value)>
241 template<_ConstExprParam _Left, _ConstExprParam _Right>
242 friend constexpr auto
243 operator%(_Left, _Right)
noexcept
244 -> constant_wrapper<(_Left::value % _Right::value)>
247 template<_ConstExprParam _Left, _ConstExprParam _Right>
248 friend constexpr auto
250 -> constant_wrapper<(_Left::value << _Right::value)>
253 template<_ConstExprParam _Left, _ConstExprParam _Right>
254 friend constexpr auto
256 -> constant_wrapper<(_Left::value >> _Right::value)>
259 template<_ConstExprParam _Left, _ConstExprParam _Right>
260 friend constexpr auto
262 -> constant_wrapper<(_Left::value & _Right::value)>
265 template<_ConstExprParam _Left, _ConstExprParam _Right>
266 friend constexpr auto
268 -> constant_wrapper<(_Left::value | _Right::value)>
271 template<_ConstExprParam _Left, _ConstExprParam _Right>
272 friend constexpr auto
274 -> constant_wrapper<(_Left::value ^ _Right::value)>
277 template<_ConstExprParam _Left, _ConstExprParam _Right>
278 requires (!is_constructible_v<bool,
decltype(_Left::value)>
279 || !is_constructible_v<bool,
decltype(_Right::value)>)
280 friend constexpr auto
281 operator&&(_Left, _Right)
noexcept
282 -> constant_wrapper<(_Left::value && _Right::value)>
285 template<_ConstExprParam _Left, _ConstExprParam _Right>
286 requires (!is_constructible_v<bool,
decltype(_Left::value)>
287 || !is_constructible_v<bool,
decltype(_Right::value)>)
288 friend constexpr auto
289 operator||(_Left, _Right)
noexcept
290 -> constant_wrapper<(_Left::value || _Right::value)>
293 template<_ConstExprParam _Left, _ConstExprParam _Right>
294 friend constexpr auto
295 operator<=>(_Left, _Right)
noexcept
296 -> constant_wrapper<(_Left::value <=> _Right::value)>
299 template<_ConstExprParam _Left, _ConstExprParam _Right>
300 friend constexpr auto
301 operator<(_Left, _Right)
noexcept
302 -> constant_wrapper<(_Left::value < _Right::value)>
305 template<_ConstExprParam _Left, _ConstExprParam _Right>
306 friend constexpr auto
307 operator<=(_Left, _Right)
noexcept
308 -> constant_wrapper<(_Left::value <= _Right::value)>
311 template<_ConstExprParam _Left, _ConstExprParam _Right>
312 friend constexpr auto
313 operator==(_Left, _Right)
noexcept
314 -> constant_wrapper<(_Left::value == _Right::value)>
317 template<_ConstExprParam _Left, _ConstExprParam _Right>
318 friend constexpr auto
319 operator!=(_Left, _Right)
noexcept
320 -> constant_wrapper<(_Left::value != _Right::value)>
323 template<_ConstExprParam _Left, _ConstExprParam _Right>
324 friend constexpr auto
325 operator>(_Left, _Right)
noexcept
326 -> constant_wrapper<(_Left::value > _Right::value)>
329 template<_ConstExprParam _Left, _ConstExprParam _Right>
330 friend constexpr auto
331 operator>=(_Left, _Right)
noexcept
332 -> constant_wrapper<(_Left::value >= _Right::value)>
335 template<_ConstExprParam _Left, _ConstExprParam _Right>
336 friend constexpr auto
337 operator,(_Left, _Right)
noexcept =
delete;
339 template<_ConstExprParam _Left, _ConstExprParam _Right>
340 friend constexpr auto
341 operator->*(_Left, _Right)
noexcept
342 -> constant_wrapper<_Left::value->*(_Right::value)>
345 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
347 operator()(
this _Tp, _Args...) noexcept
349 requires(_Args...) { constant_wrapper<_Tp::value(_Args::value...)>(); }
350 {
return constant_wrapper<_Tp::value(_Args::value...)>{}; }
352 template<_ConstExprParam _Tp, _ConstExprParam... _Args>
354 operator[](
this _Tp, _Args...) noexcept
355 -> constant_wrapper<(_Tp::value[_Args::value...])>
358 template<_ConstExprParam _Tp>
360 operator++(
this _Tp)
noexcept
361 -> constant_wrapper<(++_Tp::value)>
364 template<_ConstExprParam _Tp>
366 operator++(
this _Tp,
int)
noexcept
367 -> constant_wrapper<(_Tp::value++)>
370 template<_ConstExprParam _Tp>
372 operator--(
this _Tp)
noexcept
373 -> constant_wrapper<(--_Tp::value)>
376 template<_ConstExprParam _Tp>
378 operator--(
this _Tp,
int)
noexcept
379 -> constant_wrapper<(_Tp::value--)>
382 template<_ConstExprParam _Tp, _ConstExprParam _Right>
384 operator+=(
this _Tp, _Right)
noexcept
385 -> constant_wrapper<(_Tp::value += _Right::value)>
388 template<_ConstExprParam _Tp, _ConstExprParam _Right>
390 operator-=(
this _Tp, _Right)
noexcept
391 -> constant_wrapper<(_Tp::value -= _Right::value)>
394 template<_ConstExprParam _Tp, _ConstExprParam _Right>
396 operator*=(
this _Tp, _Right)
noexcept
397 -> constant_wrapper<(_Tp::value *= _Right::value)>
400 template<_ConstExprParam _Tp, _ConstExprParam _Right>
402 operator/=(
this _Tp, _Right)
noexcept
403 -> constant_wrapper<(_Tp::value /= _Right::value)>
406 template<_ConstExprParam _Tp, _ConstExprParam _Right>
408 operator%=(
this _Tp, _Right)
noexcept
409 -> constant_wrapper<(_Tp::value %= _Right::value)>
412 template<_ConstExprParam _Tp, _ConstExprParam _Right>
414 operator&=(
this _Tp, _Right)
noexcept
415 -> constant_wrapper<(_Tp::value &= _Right::value)>
418 template<_ConstExprParam _Tp, _ConstExprParam _Right>
420 operator|=(
this _Tp, _Right)
noexcept
421 -> constant_wrapper<(_Tp::value |= _Right::value)>
424 template<_ConstExprParam _Tp, _ConstExprParam _Right>
426 operator^=(
this _Tp, _Right)
noexcept
427 -> constant_wrapper<(_Tp::value ^= _Right::value)>
430 template<_ConstExprParam _Tp, _ConstExprParam _Right>
432 operator<<=(
this _Tp, _Right)
noexcept
433 -> constant_wrapper<(_Tp::value <<= _Right::value)>
436 template<_ConstExprParam _Tp, _ConstExprParam _Right>
438 operator>>=(
this _Tp, _Right)
noexcept
439 -> constant_wrapper<(_Tp::value >>= _Right::value)>
443 template<_CwFixedValue _Xv,
typename>
444 struct constant_wrapper : _CwOperators
446 static constexpr const auto& value = _Xv._M_data;
447 using type = constant_wrapper;
448 using value_type =
typename decltype(_Xv)::__type;
450 template<_ConstExprParam _Right>
452 operator=(_Right)
const noexcept
453 -> constant_wrapper<(value = _Right::value)>
457 operator decltype(value)()
const noexcept
462 constexpr bool __is_constant_wrapper_v =
false;
464 template<auto __cw,
typename _Fn>
465 constexpr bool __is_constant_wrapper_v<constant_wrapper<__cw, _Fn>> =
true;
467 template<_CwFixedValue _Tp>
468 constexpr auto cw = constant_wrapper<_Tp>{};
471#ifdef __glibcxx_integer_sequence
474 template<
typename _Tp, _Tp... _Idx>
477#if __cplusplus >= 202002L
478 static_assert(is_integral_v<_Tp>);
480 typedef _Tp value_type;
481 static constexpr size_t size()
noexcept {
return sizeof...(_Idx); }
484#if __glibcxx_integer_sequence >= 202511L
491 template<
typename _Tp, _Tp... _Idx>
495 template<
size_t __i,
class _Tp, _Tp... _Idx>
496 struct tuple_element<__i, integer_sequence<_Tp, _Idx...>>
498 static_assert(__i <
sizeof...(_Idx));
502 template<
size_t __i,
class _Tp, _Tp... _Idx>
505 static_assert(__i <
sizeof...(_Idx));
509 template<
size_t __i,
class _Tp, _Tp... _Idx>
514 static_assert(__i <
sizeof...(_Idx));
521 template<
typename _Tp, _Tp _Num>
523#if __has_builtin(__make_integer_seq)
524 = __make_integer_seq<integer_sequence, _Tp, _Num>;
530 template<
size_t... _Idx>
534 template<
size_t _Num>
538 template<
typename... _Types>
542#if __cpp_structured_bindings >= 202411L
543#if __has_builtin(__integer_pack)
544 template <auto _Num,
typename _Tp = decltype(_Num)>
546 _IotaArray[_Num] = {__integer_pack(_Tp(_Num))...};
547#elif defined __glibcxx_integer_sequence
548 template <auto _Num,
typename _Tp = decltype(_Num),
typename = make_
integer_sequence<_Tp, _Num>>
552 template <
auto _Num,
typename _Tp, _Tp... _Is>
554 _IotaArray<_Num, _Tp, integer_sequence<_Tp, _Is...>>[_Num] = {_Is...};
558#if __cplusplus >= 201703L
561 explicit in_place_t() =
default;
564 inline constexpr in_place_t in_place{};
566 template<
typename _Tp>
struct in_place_type_t
568 explicit in_place_type_t() =
default;
571 template<
typename _Tp>
572 inline constexpr in_place_type_t<_Tp> in_place_type{};
574 template<
size_t _Idx>
struct in_place_index_t
576 explicit in_place_index_t() =
default;
579 template<
size_t _Idx>
580 inline constexpr in_place_index_t<_Idx> in_place_index{};
583 inline constexpr bool __is_in_place_type_v =
false;
585 template<
typename _Tp>
586 inline constexpr bool __is_in_place_type_v<in_place_type_t<_Tp>> =
true;
589 inline constexpr bool __is_in_place_index_v =
false;
592 inline constexpr bool __is_in_place_index_v<in_place_index_t<_Nm>> =
true;
596#if _GLIBCXX_USE_BUILTIN_TRAIT(__type_pack_element)
597 template<
size_t _Np,
typename... _Types>
599 {
using type = __type_pack_element<_Np, _Types...>; };
601 template<
size_t _Np,
typename... _Types>
605 template<
typename _Tp0,
typename... _Rest>
606 struct _Nth_type<0, _Tp0, _Rest...>
607 {
using type = _Tp0; };
609 template<
typename _Tp0,
typename _Tp1,
typename... _Rest>
610 struct _Nth_type<1, _Tp0, _Tp1, _Rest...>
611 {
using type = _Tp1; };
613 template<
typename _Tp0,
typename _Tp1,
typename _Tp2,
typename... _Rest>
614 struct _Nth_type<2, _Tp0, _Tp1, _Tp2, _Rest...>
615 {
using type = _Tp2; };
617 template<
size_t _Np,
typename _Tp0,
typename _Tp1,
typename _Tp2,
622 struct _Nth_type<_Np, _Tp0, _Tp1, _Tp2, _Rest...>
623 : _Nth_type<_Np - 3, _Rest...>
627 template<
typename _Tp0,
typename _Tp1,
typename _Tp2,
typename... _Rest>
628 struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
629 {
using type = _Tp0; };
631 template<
typename _Tp0,
typename _Tp1,
typename _Tp2,
typename... _Rest>
632 struct _Nth_type<1, _Tp0, _Tp1, _Tp2, _Rest...>
633 {
using type = _Tp1; };
638 namespace ranges::__detail
640 template<
typename _Range>
641 inline constexpr bool __is_subrange =
false;
647 struct _Swallow_assign
650 constexpr const _Swallow_assign&
651 operator=(
const _Tp&)
const noexcept
672 _GLIBCXX17_INLINE
constexpr _Swallow_assign
ignore{};
674#if __glibcxx_flat_map || __glibcxx_flat_set
675 struct sorted_unique_t {
explicit sorted_unique_t() =
default; };
676 inline constexpr sorted_unique_t sorted_unique{};
678 struct sorted_equivalent_t {
explicit sorted_equivalent_t() =
default; };
679 inline constexpr sorted_equivalent_t sorted_equivalent{};
682_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
ISO C++ entities toplevel namespace is std.
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
integer_sequence< size_t, _Idx... > index_sequence
Alias template index_sequence.
__make_integer_seq< integer_sequence, _Tp, _Num > make_integer_sequence
Alias template make_integer_sequence.
constexpr _Swallow_assign ignore
constexpr bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
constexpr bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
make_index_sequence< sizeof...(_Types)> index_sequence_for
Alias template index_sequence_for.
constexpr bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Define a member typedef type only if a boolean constant is true.
Finds the size of a given tuple type.
Gives the type of the ith element of a given tuple type.
Class template integer_sequence.