aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/units.hpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/kstd/kstd/units.hpp b/libs/kstd/kstd/units.hpp
index df5eb374..6e9ea1e2 100644
--- a/libs/kstd/kstd/units.hpp
+++ b/libs/kstd/kstd/units.hpp
@@ -22,7 +22,8 @@ namespace kstd
: value{value}
{}
- explicit constexpr operator value_type() const noexcept
+ template<std::integral T>
+ explicit constexpr operator T() const noexcept
{
return value;
}
@@ -47,7 +48,7 @@ namespace kstd
return *this = *this - other;
}
- constexpr auto operator*(std::integral auto factor) noexcept -> basic_unit
+ constexpr auto operator*(std::integral auto factor) const noexcept -> basic_unit
{
return basic_unit{value * factor};
}
@@ -57,7 +58,7 @@ namespace kstd
return *this = *this * factor;
}
- constexpr auto operator/(std::integral auto divisor) noexcept -> basic_unit
+ constexpr auto operator/(std::integral auto divisor) const noexcept -> basic_unit
{
return basic_unit{value / divisor};
}
@@ -72,6 +73,11 @@ namespace kstd
return value / other.value;
}
+ constexpr auto operator%(basic_unit const & other) const noexcept -> basic_unit
+ {
+ return basic_unit{value % other.value};
+ }
+
constexpr auto operator<=>(basic_unit const & other) const noexcept -> std::strong_ordering = default;
value_type value;