8#ifndef LIBFXD_TRAITS_HPP
9#define LIBFXD_TRAITS_HPP
21 struct is_fixed_point :
27 template<
int Int,
int Frac,
typename Raw>
28 struct is_fixed_point<
fixed<Int, Frac, Raw>> :
40 struct is_signed_fixed_point : std::false_type {};
44 template<
int Int,
int Frac,
typename Raw>
45 struct is_signed_fixed_point<
fixed<Int, Frac, Raw>> :
46 std::is_signed<Raw> {};
56 struct is_unsigned_fixed_point : std::false_type {};
60 template<
int Int,
int Frac,
typename Raw>
61 struct is_unsigned_fixed_point<fixed<Int, Frac, Raw>> :
62 std::is_unsigned<Raw> {};
67 bool is_unsigned_fixed_point_v = is_unsigned_fixed_point<T>::value;
72 requires (is_fixed_point_v<T>)
73 struct make_unsigned {
74 using type = fixed<T::int_bits,
76 std::make_unsigned_t<typename T::raw_type>>;
81 using make_unsigned_t =
typename make_unsigned<T>::type;
90 template<
typename Fxd>
91 requires (fxd::is_fixed_point_v<Fxd>)
92 struct common_type<Fxd, Fxd> {
100 template<
typename Fxd1,
102 requires (fxd::is_fixed_point_v<Fxd1> && fxd::is_fixed_point_v<Fxd2>
104 (is_convertible_v<Fxd1, Fxd2> || is_convertible_v<Fxd2, Fxd1>))
105 struct common_type<Fxd1, Fxd2> {
107 is_convertible_v<Fxd2, Fxd1>,
115 template<
typename Fxd,
117 requires (fxd::is_fixed_point_v<Fxd> && is_arithmetic_v<Other>)
118 struct common_type<Fxd, Other> {
126 template<
typename Other,
128 requires (is_arithmetic_v<Other> && fxd::is_fixed_point_v<Fxd>)
129 struct common_type<Other, Fxd> {
This is the namespace where the entire library is defined.
constexpr bool is_signed_fixed_point_v
Helper template variable for fxd::is_signed_fixed_point
constexpr bool is_fixed_point_v
Helper template variable for fxd::is_fixed_point
The fixed-point class template.
conditional_t< is_convertible_v< Fxd2, Fxd1 >, Fxd1, Fxd2 > type