9
9
#ifndef _LIBCPP___UTILITY_CMP_H
10
10
#define _LIBCPP___UTILITY_CMP_H
11
11
12
+ #include < __concepts/arithmetic.h>
12
13
#include < __config>
13
- #include < __type_traits/disjunction.h>
14
- #include < __type_traits/is_integral.h>
15
- #include < __type_traits/is_same.h>
16
14
#include < __type_traits/is_signed.h>
17
15
#include < __type_traits/make_unsigned.h>
18
- #include < __utility/forward.h>
19
- #include < __utility/move.h>
20
16
#include < limits>
21
17
22
18
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -29,28 +25,8 @@ _LIBCPP_PUSH_MACROS
29
25
_LIBCPP_BEGIN_NAMESPACE_STD
30
26
31
27
#if _LIBCPP_STD_VER >= 20
32
- template <class _Tp , class ... _Up>
33
- struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {};
34
-
35
- template <class _Tp >
36
- concept __is_safe_integral_cmp =
37
- is_integral_v<_Tp> &&
38
- !_IsSameAsAny<_Tp,
39
- bool ,
40
- char ,
41
- char16_t ,
42
- char32_t
43
- # ifndef _LIBCPP_HAS_NO_CHAR8_T
44
- ,
45
- char8_t
46
- # endif
47
- # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
48
- ,
49
- wchar_t
50
- # endif
51
- >::value;
52
-
53
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
28
+
29
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
54
30
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal (_Tp __t , _Up __u) noexcept {
55
31
if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
56
32
return __t == __u;
@@ -60,12 +36,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept {
60
36
return __u < 0 ? false : __t == make_unsigned_t <_Up>(__u);
61
37
}
62
38
63
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
39
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
64
40
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal (_Tp __t , _Up __u) noexcept {
65
41
return !std::cmp_equal (__t , __u);
66
42
}
67
43
68
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
44
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
69
45
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less (_Tp __t , _Up __u) noexcept {
70
46
if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
71
47
return __t < __u;
@@ -75,26 +51,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept {
75
51
return __u < 0 ? false : __t < make_unsigned_t <_Up>(__u);
76
52
}
77
53
78
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
54
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
79
55
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater (_Tp __t , _Up __u) noexcept {
80
56
return std::cmp_less (__u, __t );
81
57
}
82
58
83
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
59
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
84
60
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal (_Tp __t , _Up __u) noexcept {
85
61
return !std::cmp_greater (__t , __u);
86
62
}
87
63
88
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
64
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
89
65
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal (_Tp __t , _Up __u) noexcept {
90
66
return !std::cmp_less (__t , __u);
91
67
}
92
68
93
- template <__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
69
+ template <__libcpp_integer _Tp, __libcpp_integer _Up>
94
70
_LIBCPP_HIDE_FROM_ABI constexpr bool in_range (_Up __u) noexcept {
95
71
return std::cmp_less_equal (__u, numeric_limits<_Tp>::max ()) &&
96
72
std::cmp_greater_equal (__u, numeric_limits<_Tp>::min ());
97
73
}
74
+
98
75
#endif // _LIBCPP_STD_VER >= 20
99
76
100
77
_LIBCPP_END_NAMESPACE_STD
0 commit comments