|
jam 0.0.1
A compacting generational garbage collector for C++26
|
Typed space units, conversions and size literals. More...
#include <chrono>#include <cmath>#include <compare>#include <concepts>#include <cstddef>#include <cstdint>#include <cstdio>#include <cstdlib>#include <limits>#include <ratio>#include <type_traits>Go to the source code of this file.
Classes | |
| class | jam::units::space< Rep, Ratio > |
| A count of storage units; Ratio measures one unit in bytes. Integer arithmetic and conversions terminate on overflow. Floating arithmetic follows its representation. Like chrono, integral destinations accept only lossless unit conversions implicitly; use space_cast, floor, ceil or round otherwise. There is no implicit conversion to an untyped count. More... | |
| struct | std::common_type< jam::units::space< R1, P1 >, jam::units::space< R2, P2 > > |
| Common representation and greatest common unit, as for chrono durations. More... | |
Namespaces | |
| namespace | jam::literals |
| Decimal and binary byte literals; counts retain their units. | |
Typedefs | |
| using | jam::units::kibi = std::ratio<1024> |
| Binary kilo: 1024. | |
| using | jam::units::mebi = std::ratio<1048576> |
| Binary mega: 1024 squared. | |
| using | jam::units::gibi = std::ratio<1073741824> |
| Binary giga: 1024 cubed. | |
| using | jam::units::bytes = space<std::size_t> |
| Whole bytes. | |
| using | jam::units::kilobytes = space<std::size_t, std::kilo> |
| Thousands of bytes. | |
| using | jam::units::megabytes = space<std::size_t, std::mega> |
| Millions of bytes. | |
| using | jam::units::gigabytes = space<std::size_t, std::giga> |
| Billions of bytes. | |
| using | jam::units::kibibytes = space<std::size_t, kibi> |
| Groups of 1024 bytes. | |
| using | jam::units::mebibytes = space<std::size_t, mebi> |
| Groups of 1048576 bytes. | |
| using | jam::units::gibibytes = space<std::size_t, gibi> |
| Groups of 1073741824 bytes. | |
| using | jam::units::pages = space<std::size_t, std::ratio<JAM_PAGE_BYTES>> |
| Platform pages, fixed at build time. | |
Functions | |
| template<class To, class R, class P> | |
| constexpr To | jam::units::space_cast (space< R, P > value) noexcept |
| Explicit conversion; fractional integral ticks truncate toward zero. | |
| template<class R1, class P1, class R2, class P2> | |
| constexpr auto | jam::units::operator<=> (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Compare amounts without overflowing an integral common-unit conversion. | |
| template<class R1, class P1, class R2, class P2> | |
| constexpr bool | jam::units::operator== (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Equal amounts may have different units or representations. | |
| template<class R1, class P1, class R2, class P2> | |
| constexpr auto | jam::units::operator+ (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Add amounts in their common unit. | |
| template<class R1, class P1, class R2, class P2> | |
| constexpr auto | jam::units::operator- (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Subtract amounts in their common unit. | |
|
template<class R, class P, class S> requires std::is_arithmetic_v<S> | |
| constexpr auto | jam::units::operator* (space< R, P > a, S b) noexcept |
| Multiply an amount by a scalar, preserving its unit. | |
|
template<class R, class P, class S> requires std::is_arithmetic_v<S> | |
| constexpr auto | jam::units::operator* (S a, space< R, P > b) noexcept |
| Multiply a scalar by an amount. | |
|
template<class R, class P, class S> requires std::is_arithmetic_v<S> | |
| constexpr auto | jam::units::operator/ (space< R, P > a, S b) noexcept |
| Divide an amount by a scalar, preserving its unit. | |
| template<class R1, class P1, class R2, class P2> | |
| constexpr auto | jam::units::operator/ (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Divide two amounts, producing a dimensionless count. | |
| template<std::integral R, class P, std::integral S> | |
| constexpr auto | jam::units::operator% (space< R, P > a, S b) noexcept |
| Integral remainder in the original unit. | |
| template<std::integral R1, class P1, std::integral R2, class P2> | |
| constexpr auto | jam::units::operator% (space< R1, P1 > a, space< R2, P2 > b) noexcept |
| Integral remainder in the common unit. | |
| template<class To, class R, class P> | |
| constexpr To | jam::units::floor (space< R, P > value) noexcept |
| Greatest whole destination count not exceeding the source. | |
| template<class To, class R, class P> | |
| constexpr To | jam::units::ceil (space< R, P > value) noexcept |
| Least whole destination count not less than the source. | |
|
template<class To, class R, class P> requires std::integral<typename To::rep> | |
| constexpr To | jam::units::round (space< R, P > value) noexcept |
| Nearest integral destination count; ties round to even. | |
|
template<class R, class P> requires std::is_signed_v<R> | |
| constexpr auto | jam::units::abs (space< R, P > value) noexcept |
| Absolute value of a signed amount. | |
| consteval units::bytes | jam::literals::operator""_B (unsigned long long n) noexcept |
| Bytes. | |
| consteval units::space< long double, std::ratio< 1 > > | jam::literals::operator""_B (long double n) noexcept |
| Fractional B count. | |
| consteval units::kilobytes | jam::literals::operator""_kB (unsigned long long n) noexcept |
| Kilobytes. | |
| consteval units::space< long double, std::kilo > | jam::literals::operator""_kB (long double n) noexcept |
| Fractional kB count. | |
| consteval units::megabytes | jam::literals::operator""_MB (unsigned long long n) noexcept |
| Megabytes. | |
| consteval units::space< long double, std::mega > | jam::literals::operator""_MB (long double n) noexcept |
| Fractional MB count. | |
| consteval units::gigabytes | jam::literals::operator""_GB (unsigned long long n) noexcept |
| Gigabytes. | |
| consteval units::space< long double, std::giga > | jam::literals::operator""_GB (long double n) noexcept |
| Fractional GB count. | |
| consteval units::kibibytes | jam::literals::operator""_KiB (unsigned long long n) noexcept |
| Kibibytes. | |
| consteval units::space< long double, units::kibi > | jam::literals::operator""_KiB (long double n) noexcept |
| Fractional KiB count. | |
| consteval units::mebibytes | jam::literals::operator""_MiB (unsigned long long n) noexcept |
| Mebibytes. | |
| consteval units::space< long double, units::mebi > | jam::literals::operator""_MiB (long double n) noexcept |
| Fractional MiB count. | |
| consteval units::gibibytes | jam::literals::operator""_GiB (unsigned long long n) noexcept |
| Gibibytes. | |
| consteval units::space< long double, units::gibi > | jam::literals::operator""_GiB (long double n) noexcept |
| Fractional GiB count. | |
Typed space units, conversions and size literals.
Definition in file units.ccm.