9
9
#ifndef _LIBCPP___UTILITY_CMP_H
10
10
#define _LIBCPP___UTILITY_CMP_H
11
11
12
+ #include " __assert"
12
13
#include < __config>
13
14
#include < __type_traits/integer_traits.h>
14
15
#include < __type_traits/is_signed.h>
@@ -28,13 +29,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28
29
29
30
template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
30
31
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal (_Tp __t , _Up __u) noexcept {
31
- if constexpr (sizeof (_Tp) < sizeof (int ) && sizeof (_Up) < sizeof (int )) {
32
- __builtin_assume (__t < numeric_limits<int >::max () && __u < numeric_limits<int >::max ());
32
+ if constexpr (sizeof (_Tp) < sizeof (int ) && sizeof (_Up) < sizeof (int ))
33
33
return static_cast <int >(__t ) == static_cast <int >(__u);
34
- } else if constexpr (sizeof (_Tp) < sizeof (long long ) && sizeof (_Up) < sizeof (long long )) {
35
- __builtin_assume (__t < numeric_limits<long long >::max () && __u < numeric_limits<long long >::max ());
34
+ else if constexpr (sizeof (_Tp) < sizeof (long long ) && sizeof (_Up) < sizeof (long long ))
36
35
return static_cast <long long >(__t ) == static_cast <long long >(__u);
37
- } else if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
36
+ else if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
38
37
return __t == __u;
39
38
else if constexpr (is_signed_v<_Tp>)
40
39
return __t < 0 ? false : make_unsigned_t <_Tp>(__t ) == __u;
@@ -49,13 +48,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept {
49
48
50
49
template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
51
50
_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less (_Tp __t , _Up __u) noexcept {
52
- if constexpr (sizeof (_Tp) < sizeof (int ) && sizeof (_Up) < sizeof (int )) {
53
- __builtin_assume (__t < numeric_limits<int >::max () && __u < numeric_limits<int >::max ());
51
+ if constexpr (sizeof (_Tp) < sizeof (int ) && sizeof (_Up) < sizeof (int ))
54
52
return static_cast <int >(__t ) < static_cast <int >(__u);
55
- } else if constexpr (sizeof (_Tp) < sizeof (long long ) && sizeof (_Up) < sizeof (long long )) {
56
- __builtin_assume (__t < numeric_limits<long long >::max () && __u < numeric_limits<long long >::max ());
53
+ else if constexpr (sizeof (_Tp) < sizeof (long long ) && sizeof (_Up) < sizeof (long long ))
57
54
return static_cast <long long >(__t ) < static_cast <long long >(__u);
58
- } else if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
55
+ else if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
59
56
return __t < __u;
60
57
else if constexpr (is_signed_v<_Tp>)
61
58
return __t < 0 ? true : make_unsigned_t <_Tp>(__t ) < __u;
0 commit comments