diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-16 17:30:17 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-16 17:30:17 +0200 |
| commit | 604c2a843d95921e0429ebbdd5849174e47a9547 (patch) | |
| tree | 79adbeeb843926c2a60bbc8b645cf073c8a3f1f1 /libs/kstd | |
| parent | a6166befa7421be233ece97e184139870bbc0af7 (diff) | |
| download | kernel-604c2a843d95921e0429ebbdd5849174e47a9547.tar.xz kernel-604c2a843d95921e0429ebbdd5849174e47a9547.zip | |
kernel: begin block device re-architecture work
Diffstat (limited to 'libs/kstd')
| -rw-r--r-- | libs/kstd/kstd/units.hpp | 12 |
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; |
