@@ -26,28 +26,28 @@ template <typename T>
26
26
LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_fixed_point_v<T>, T>
27
27
bit_and (T x, T y) {
28
28
using BitType = typename FXRep<T>::StorageType;
29
- static_assert (sizeof (BitType) * CHAR_BIT == sizeof (T) * CHAR_BIT);
30
29
BitType x_bit = cpp::bit_cast<BitType>(x);
31
30
BitType y_bit = cpp::bit_cast<BitType>(y);
31
+ // For some reason, bit_cast cannot deduce BitType from the input.
32
32
return cpp::bit_cast<T, BitType>(x_bit & y_bit);
33
33
}
34
34
35
35
template <typename T>
36
36
LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_fixed_point_v<T>, T>
37
37
bit_or (T x, T y) {
38
38
using BitType = typename FXRep<T>::StorageType;
39
- static_assert (sizeof (BitType) * CHAR_BIT == FXRep<T>::TOTAL_LEN);
40
39
BitType x_bit = cpp::bit_cast<BitType>(x);
41
40
BitType y_bit = cpp::bit_cast<BitType>(y);
41
+ // For some reason, bit_cast cannot deduce BitType from the input.
42
42
return cpp::bit_cast<T, BitType>(x_bit | y_bit);
43
43
}
44
44
45
45
template <typename T>
46
46
LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_fixed_point_v<T>, T>
47
47
bit_not (T x) {
48
48
using BitType = typename FXRep<T>::StorageType;
49
- static_assert (sizeof (BitType) * CHAR_BIT == sizeof (T) * CHAR_BIT);
50
49
BitType x_bit = cpp::bit_cast<BitType>(x);
50
+ // For some reason, bit_cast cannot deduce BitType from the input.
51
51
return cpp::bit_cast<T, BitType>(~x_bit);
52
52
}
53
53
0 commit comments