55#ifndef _GLIBCXX_UTILITY
56#define _GLIBCXX_UTILITY 1
59#pragma GCC system_header
73#if __cplusplus >= 201103L
80#if __cplusplus >= 202002L
84#if __cplusplus > 202302L
88#define __glibcxx_want_addressof_constexpr
89#define __glibcxx_want_as_const
90#define __glibcxx_want_constexpr_algorithms
91#define __glibcxx_want_constexpr_utility
92#define __glibcxx_want_exchange_function
93#define __glibcxx_want_forward_like
94#define __glibcxx_want_integer_comparison_functions
95#define __glibcxx_want_integer_sequence
96#define __glibcxx_want_ranges_zip
97#define __glibcxx_want_to_underlying
98#define __glibcxx_want_tuple_element_t
99#define __glibcxx_want_tuples_by_type
100#define __glibcxx_want_unreachable
101#define __glibcxx_want_observable_checkpoint
102#define __glibcxx_want_tuple_like
103#define __glibcxx_want_constrained_equality
106namespace std _GLIBCXX_VISIBILITY(default)
108_GLIBCXX_BEGIN_NAMESPACE_VERSION
110#ifdef __cpp_lib_exchange_function
112 template <typename _Tp, typename _Up = _Tp>
115 exchange(_Tp& __obj, _Up&& __new_val)
116 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
121#ifdef __cpp_lib_as_const
122 template<
typename _Tp>
124 constexpr add_const_t<_Tp>&
125 as_const(_Tp& __t)
noexcept
128 template<
typename _Tp>
129 void as_const(
const _Tp&&) =
delete;
132#ifdef __cpp_lib_integer_comparison_functions
133 template<
typename _Tp,
typename _Up>
135 cmp_equal(_Tp __t, _Up __u)
noexcept
137 static_assert(__is_standard_integer<_Tp>::value);
138 static_assert(__is_standard_integer<_Up>::value);
140 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
142 else if constexpr (is_signed_v<_Tp>)
148 template<
typename _Tp,
typename _Up>
150 cmp_not_equal(_Tp __t, _Up __u)
noexcept
151 {
return !std::cmp_equal(__t, __u); }
153 template<
typename _Tp,
typename _Up>
155 cmp_less(_Tp __t, _Up __u)
noexcept
157 static_assert(__is_standard_integer<_Tp>::value);
158 static_assert(__is_standard_integer<_Up>::value);
160 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
162 else if constexpr (is_signed_v<_Tp>)
165 return __u >= 0 && __t < make_unsigned_t<_Up>(__u);
168 template<
typename _Tp,
typename _Up>
170 cmp_greater(_Tp __t, _Up __u)
noexcept
171 {
return std::cmp_less(__u, __t); }
173 template<
typename _Tp,
typename _Up>
175 cmp_less_equal(_Tp __t, _Up __u)
noexcept
176 {
return !std::cmp_less(__u, __t); }
178 template<
typename _Tp,
typename _Up>
180 cmp_greater_equal(_Tp __t, _Up __u)
noexcept
181 {
return !std::cmp_less(__t, __u); }
183 template<
typename _Res,
typename _Tp>
185 in_range(_Tp __t)
noexcept
187 static_assert(__is_standard_integer<_Res>::value);
188 static_assert(__is_standard_integer<_Tp>::value);
191 if constexpr (is_signed_v<_Tp> == is_signed_v<_Res>)
192 return __int_traits<_Res>::__min <= __t
193 && __t <= __int_traits<_Res>::__max;
194 else if constexpr (is_signed_v<_Tp>)
198 return __t <= make_unsigned_t<_Res>(__int_traits<_Res>::__max);
202#ifdef __cpp_lib_to_underlying
204 template<typename _Tp>
205 [[nodiscard, __gnu__::__always_inline__]]
207 to_underlying(_Tp __value)
noexcept
211#ifdef __cpp_lib_unreachable
224 [[noreturn,__gnu__::__always_inline__]]
229 std::__glibcxx_assert_fail(
nullptr, 0,
"std::unreachable()",
nullptr);
230#elif defined _GLIBCXX_ASSERTIONS
233 __builtin_unreachable();
239#ifdef __cpp_lib_observable_checkpoint
248 [[__gnu__::__always_inline__]]
250 observable_checkpoint() noexcept
252 return __builtin_observable_checkpoint();
256_GLIBCXX_END_NAMESPACE_VERSION
typename underlying_type< _Tp >::type underlying_type_t
Alias template for underlying_type.
typename make_unsigned< _Tp >::type make_unsigned_t
Alias template for make_unsigned.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.