9 #ifndef EAGINE_UNITS_UNIT_HPP
10 #define EAGINE_UNITS_UNIT_HPP
16 namespace eagine::units {
19 template <
typename Dims,
typename System>
21 using dimension = Dims;
22 using system = System;
23 using scale = scales::one;
28 auto get_dimension(X) noexcept {
29 return dimension_of_t<X>{};
33 template <
typename D,
typename S>
34 struct value_conv<unit<D, S>, unit<D, S>> : trivial_value_conv {};
37 template <
typename D,
typename S>
38 struct add_result<unit<D, S>, unit<D, S>> : unit<D, S> {};
41 template <
typename D,
typename S>
42 struct sub_result<unit<D, S>, unit<D, S>> : unit<D, S> {};
45 template <
typename D1,
typename D2,
typename S>
46 struct mul_l_operand<unit<D1, S>, unit<D2, S>> : unit<D1, S> {};
49 template <
typename D1,
typename D2,
typename S>
50 struct mul_r_operand<unit<D1, S>, unit<D2, S>> : unit<D2, S> {};
53 template <
typename D1,
typename D2,
typename S>
54 struct mul_result<unit<D1, S>, unit<D2, S>>
55 : unit<bits::dim_add_t<D1, D2>, S> {};
58 template <
typename D1,
typename D2,
typename S>
59 struct div_result<unit<D1, S>, unit<D2, S>>
60 : unit<bits::dim_sub_t<D1, D2>, S> {};
64 static constexpr
auto operator!(U) noexcept
65 -> std::enable_if_t<is_unit_v<U>, lit_result_t<U>> {
70 template <
typename U1,
typename U2>
71 static constexpr
auto operator+(U1, U2) noexcept
72 -> std::enable_if_t<is_unit_v<U1> && is_unit_v<U2>, add_result_t<U1, U2>> {
77 template <
typename U1,
typename U2>
78 static constexpr
auto operator-(U1, U2) noexcept
79 -> std::enable_if_t<is_unit_v<U1> && is_unit_v<U2>, sub_result_t<U1, U2>> {
84 template <
typename U1,
typename U2>
85 static constexpr
auto operator*(U1, U2) noexcept
86 -> std::enable_if_t<is_unit_v<U1> && is_unit_v<U2>, mul_result_t<U1, U2>> {
91 template <
typename U1,
typename U2>
92 static constexpr
auto operator/(U1, U2) noexcept
93 -> std::enable_if_t<is_unit_v<U1> && is_unit_v<U2>, div_result_t<U1, U2>> {
99 #endif // EAGINE_UNITS_UNIT_HPP