16 #include <type_traits>
21 template <
typename _target_type,
typename _rhs_T>
26 is_unit_t_v<_rhs_T> ||
28 unit_t<_rhs_T::symbol::value,
typename _rhs_T::exponent,
29 typename _rhs_T::internal_type,
typename _rhs_T::ratio>,
31 "is of type unit_t or a derived class");
33 using conversion_ratio =
34 std::ratio_divide<typename _rhs_T::ratio, typename _target_type::ratio>;
35 static_assert(std::is_convertible<decltype(conversion_ratio::den),
36 typename _rhs_T::internal_type>::value,
37 "conversion ratio denominator is convertible to internal type");
42 ((rhs.value() *
static_cast<typename _target_type::internal_type
>(
43 conversion_ratio::num)) /
44 static_cast<typename _target_type::internal_type
>(
45 conversion_ratio::den)));
48 template <
typename _unit_lhs,
typename _unit_rhs>
50 static_assert(is_unit_t_v<_unit_lhs>,
"only supported for SI::unit_t");
51 static_assert(is_unit_t_v<_unit_rhs>,
"only supported for SI::unit_t");
52 static_assert(std::is_convertible<
typename _unit_lhs::internal_type,
53 typename _unit_rhs::internal_type>::value);
54 static_assert(_unit_lhs::symbol::value == _unit_rhs::symbol::value);
56 unit_t<_unit_lhs::symbol::value,
typename _unit_lhs::exponent,
57 typename _unit_lhs::internal_type,
59 typename _unit_rhs::ratio>::ratio>;
Namespace containing implementation details for SI.
Definition: acceleration.h:34
constexpr auto unit_cast(const _rhs_T &rhs)
function to cast between two units of the same type
Definition: unit_cast.h:22
calculate gcd for rations
Definition: detail.h:32
base template class for holding values of type _type to be multiplied with a ratio _ratio
Definition: unit.h:51
Definition: unit_cast.h:49