File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,18 @@ struct numeric_limits<char8_t> {
52
52
// TODO(strager): Use std::in_range if supported.
53
53
template <class Out , class In >
54
54
constexpr bool in_range ([[maybe_unused]] In x) noexcept {
55
- using out_limits = numeric_limits<Out>;
55
+ [[maybe_unused]] constexpr Out min_out = numeric_limits<Out>::lowest ();
56
+ [[maybe_unused]] constexpr Out max_out = (numeric_limits<Out>::max)();
56
57
using unsigned_in = make_unsigned_t <In>;
57
58
using unsigned_out = make_unsigned_t <Out>;
58
59
if constexpr (std::is_same_v<In, Out>) {
59
60
return true ;
60
61
} else if constexpr (std::is_signed_v<In> == std::is_signed_v<Out>) {
61
- return out_limits::lowest () <= x && x <= (out_limits::max)() ;
62
+ return min_out <= x && x <= max_out ;
62
63
} else if constexpr (std::is_signed_v<In> && !std::is_signed_v<Out>) {
63
- return 0 <= x && static_cast <unsigned_in>(x) <= (out_limits::max)() ;
64
+ return 0 <= x && static_cast <unsigned_in>(x) <= max_out ;
64
65
} else if constexpr (!std::is_signed_v<In> && std::is_signed_v<Out>) {
65
- return x <= unsigned_out{(out_limits::max)() };
66
+ return x <= unsigned_out{max_out };
66
67
}
67
68
}
68
69
You can’t perform that action at this time.
0 commit comments