12namespace hi {
inline namespace v1 {
14template<
typename Tag,
typename T,
typename Ratio = std::ratio<1>>
20 constexpr unit(
unit const&)
noexcept =
default;
21 constexpr unit(
unit&&)
noexcept =
default;
22 constexpr unit& operator=(
unit const&)
noexcept =
default;
23 constexpr unit& operator=(
unit&&)
noexcept =
default;
25 constexpr explicit unit(value_type value) noexcept : _value(value) {}
27 template<
typename OtherT,
typename OtherRatio>
29 requires(not std::is_same_v<unit<Tag, OtherT, OtherRatio>,
unit>)
33 auto tmp = wide_cast<std::common_type_t<T, OtherT>>(
other.count());
34 tmp *= conversion::den;
35 tmp /= conversion::num;
36 _value = narrow_cast<T>(tmp);
39 template<
typename OtherT,
typename OtherRatio>
41 requires(not std::is_same_v<unit<Tag, OtherT, OtherRatio>,
unit>)
45 auto tmp = wide_cast<std::common_type_t<T, OtherT>>(
other.count());
46 tmp *= conversion::den;
47 tmp /= conversion::num;
48 _value = narrow_cast<T>(tmp);
52 [[nodiscard]]
constexpr value_type count()
const noexcept
57 [[nodiscard]]
constexpr unit operator*(value_type
const& rhs)
const noexcept
59 return unit{count() * rhs};
62 [[nodiscard]]
constexpr unit operator/(value_type
const& rhs)
const noexcept
64 return unit{count() / rhs};
67 [[nodiscard]]
constexpr unit& operator+=(
unit const& rhs)
noexcept
69 _value += rhs.count();
73 [[nodiscard]]
constexpr unit& operator-=(
unit const& rhs)
noexcept
75 _value -= rhs.count();
79 [[nodiscard]]
constexpr unit& operator*=(value_type
const& rhs)
noexcept
85 [[nodiscard]]
constexpr unit& operator/=(value_type
const& rhs)
noexcept
97template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
102 std::common_type_t<T1, T2>,
103 std::conditional_t<std::ratio_less_v<Ratio1, Ratio2>, Ratio1, Ratio2>>;
107namespace hi {
inline namespace v1 {
109template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
110[[nodiscard]]
constexpr bool operator==(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
112 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
115 hilet rhs_ = common_type{rhs};
117 return lhs_.count() == rhs_.count();
120template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
121[[nodiscard]]
constexpr auto operator<=>(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
123 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
125 hilet lhs_ = common_type{lhs};
126 hilet rhs_ = common_type{rhs};
128 return lhs_.count() <=> rhs_.count();
131template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
132[[nodiscard]]
constexpr auto operator+(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
134 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
136 hilet lhs_ = common_type{lhs};
137 hilet rhs_ = common_type{rhs};
139 return common_type{lhs_.count() + rhs_.count()};
142template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
143[[nodiscard]]
constexpr auto operator-(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
145 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
147 hilet lhs_ = common_type{lhs};
148 hilet rhs_ = common_type{rhs};
150 return common_type{lhs_.count() - rhs_.count()};
153template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
154[[nodiscard]]
constexpr auto operator/(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
156 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
158 hilet lhs_ = common_type{lhs};
159 hilet rhs_ = common_type{rhs};
161 return lhs_.count() / rhs_.count();
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11