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+=(
unit const& rhs)
noexcept
59 _value += rhs.count();
63 [[nodiscard]]
constexpr unit& operator-=(
unit const& rhs)
noexcept
65 _value -= rhs.count();
69 [[nodiscard]]
constexpr unit& operator*=(value_type
const& rhs)
noexcept
75 [[nodiscard]]
constexpr unit& operator/=(value_type
const& rhs)
noexcept
87template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
92 std::common_type_t<T1, T2>,
93 std::conditional_t<std::ratio_less_v<Ratio1, Ratio2>, Ratio1, Ratio2>>;
97namespace hi {
inline namespace v1 {
99template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
100[[nodiscard]]
constexpr bool operator==(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
102 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
105 hilet rhs_ = common_type{rhs};
107 return lhs_.count() == rhs_.count();
110template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
111[[nodiscard]]
constexpr auto operator<=>(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
113 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
115 hilet lhs_ = common_type{lhs};
116 hilet rhs_ = common_type{rhs};
118 return lhs_.count() <=> rhs_.count();
121template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
122[[nodiscard]]
constexpr auto operator+(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
124 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
126 hilet lhs_ = common_type{lhs};
127 hilet rhs_ = common_type{rhs};
129 return common_type{lhs_.count() + rhs_.count()};
132template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
133[[nodiscard]]
constexpr auto operator-(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
135 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
137 hilet lhs_ = common_type{lhs};
138 hilet rhs_ = common_type{rhs};
140 return common_type{lhs_.count() - rhs_.count()};
143template<
typename Tag,
typename T1,
typename Ratio1,
typename T2,
typename Ratio2>
144[[nodiscard]]
constexpr auto operator/(unit<Tag, T1, Ratio1>
const& lhs, unit<Tag, T2, Ratio2>
const& rhs)
noexcept
146 using common_type = std::common_type_t<unit<Tag, T1, Ratio1>, unit<Tag, T2, Ratio2>>;
148 hilet lhs_ = common_type{lhs};
149 hilet rhs_ = common_type{rhs};
151 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