Count of octets (uint64_t storage).
More...
#include <StormByte/byte_size.hxx>

Classes | |
| struct | Unit |
| One-octet scale used by the named factories. More... | |
Public Member Functions | |
| constexpr | ByteSize () noexcept |
| Zero octets. | |
| template<Type::Integral T> | |
| constexpr | ByteSize (T value) noexcept |
| From an integer octet count. | |
| constexpr | ByteSize (Size count) noexcept |
| From an abstract unit count interpreted as octets. | |
| constexpr | ByteSize (const ByteSize &other) noexcept=default |
| Copy constructor. | |
| constexpr | ByteSize (ByteSize &&other) noexcept=default |
| Move constructor. | |
| constexpr | ~ByteSize () noexcept=default |
| Destructor. | |
| constexpr ByteSize & | operator= (const ByteSize &other) noexcept=default |
| Copy assignment. | |
| constexpr ByteSize & | operator= (ByteSize &&other) noexcept=default |
| Move assignment. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator= (T value) noexcept |
| Assign an integer octet count. | |
| constexpr | operator std::size_t () const noexcept |
Implicit host size_t (clamped). | |
| template<Type::Integral T> requires (!Type::SameAs<T, std::size_t>) | |
| constexpr | operator T () const noexcept |
Explicit conversion to an integral other than std::size_t. | |
| operator CString () const noexcept | |
| IEC human-readable text owned by Base. | |
| operator WCString () const noexcept | |
| IEC human-readable wide text owned by Base. | |
| STORMBYTE_FORCE_INLINE | operator std::string () const |
| IEC human-readable text on the caller heap. | |
| constexpr ByteSize & | operator++ () noexcept |
| Prefix increment. | |
| constexpr ByteSize | operator++ (int) noexcept |
| Postfix increment. | |
| constexpr ByteSize & | operator-- () noexcept |
| Prefix decrement. | |
| constexpr ByteSize | operator-- (int) noexcept |
| Postfix decrement. | |
| ByteSize | operator* (ByteSize) const =delete |
| ByteSize & | operator*= (ByteSize)=delete |
| ByteSize | operator/ (ByteSize) const =delete |
| ByteSize & | operator/= (ByteSize)=delete |
| ByteSize | operator% (ByteSize) const =delete |
| ByteSize & | operator%= (ByteSize)=delete |
| constexpr ByteSize & | operator+= (ByteSize other) noexcept |
Add other octets. | |
| constexpr ByteSize & | operator-= (ByteSize other) noexcept |
Subtract other octets. | |
| constexpr ByteSize & | operator*= (Size other) noexcept |
| Scale by a unit count. | |
| constexpr ByteSize & | operator/= (Size other) noexcept |
| Divide by a unit count. | |
| constexpr ByteSize & | operator%= (Size other) noexcept |
| Remainder with a unit count. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator+= (T value) noexcept |
| Add an integer octet count. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator-= (T value) noexcept |
| Subtract an integer octet count. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator*= (T value) noexcept |
| Scale by an integer. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator/= (T value) noexcept |
| Divide by an integer. | |
| template<Type::Integral T> | |
| constexpr ByteSize & | operator%= (T value) noexcept |
| Remainder with an integer. | |
Static Public Attributes | |
| static constexpr Unit | B {1ull} |
| 2^0 octets | |
| static constexpr Unit | KiB {1024ull} |
| 2^10 octets | |
| static constexpr Unit | MiB {1024ull * 1024} |
| 2^20 octets | |
| static constexpr Unit | GiB {1024ull * 1024 * 1024} |
| 2^30 octets | |
| static constexpr Unit | TiB {1024ull * 1024 * 1024 * 1024} |
| 2^40 octets | |
| static constexpr Unit | PiB {1024ull * 1024 * 1024 * 1024 * 1024} |
| 2^50 octets | |
| static constexpr Unit | EiB {1024ull * 1024 * 1024 * 1024 * 1024 * 1024} |
| 2^60 octets | |
| static constexpr Unit | KB {1000ull} |
| 10^3 octets | |
| static constexpr Unit | MB {1000ull * 1000} |
| 10^6 octets | |
| static constexpr Unit | GB {1000ull * 1000 * 1000} |
| 10^9 octets | |
| static constexpr Unit | TB {1000ull * 1000 * 1000 * 1000} |
| 10^12 octets | |
| static constexpr Unit | PB {1000ull * 1000 * 1000 * 1000 * 1000} |
| 10^15 octets | |
| static constexpr Unit | EB {1000ull * 1000 * 1000 * 1000 * 1000 * 1000} |
| 10^18 octets | |
Friends | |
| constexpr bool | operator== (ByteSize lhs, ByteSize rhs) noexcept |
| Numeric equality. | |
| template<Type::Integral T> | |
| constexpr bool | operator== (ByteSize lhs, T rhs) noexcept |
| Mixed equality with an integer. | |
| template<Type::Integral T> | |
| constexpr bool | operator== (T lhs, ByteSize rhs) noexcept |
| Mixed equality with an integer. | |
| constexpr bool | operator== (ByteSize lhs, Size rhs) noexcept |
| Mixed equality with Size. | |
| constexpr bool | operator== (Size lhs, ByteSize rhs) noexcept |
| Mixed equality with Size. | |
| constexpr std::strong_ordering | operator<=> (ByteSize lhs, ByteSize rhs) noexcept |
| Numeric order. | |
| template<Type::Integral T> | |
| constexpr std::strong_ordering | operator<=> (ByteSize lhs, T rhs) noexcept |
| Mixed order with an integer. | |
| template<Type::Integral T> | |
| constexpr std::strong_ordering | operator<=> (T lhs, ByteSize rhs) noexcept |
| Mixed order with an integer. | |
| constexpr std::strong_ordering | operator<=> (ByteSize lhs, Size rhs) noexcept |
| Mixed order with Size. | |
| constexpr std::strong_ordering | operator<=> (Size lhs, ByteSize rhs) noexcept |
| Mixed order with Size. | |
| constexpr ByteSize | operator+ (ByteSize lhs, ByteSize rhs) noexcept |
| Sum of lengths. | |
| constexpr ByteSize | operator- (ByteSize lhs, ByteSize rhs) noexcept |
| Difference of lengths. | |
| constexpr ByteSize | operator* (ByteSize lhs, Size rhs) noexcept |
| Scale by a unit count. | |
| constexpr ByteSize | operator* (Size lhs, ByteSize rhs) noexcept |
| Scale by a unit count. | |
| constexpr ByteSize | operator/ (ByteSize lhs, Size rhs) noexcept |
| Divide by a unit count. | |
| constexpr ByteSize | operator% (ByteSize lhs, Size rhs) noexcept |
| Remainder with a unit count. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator+ (ByteSize lhs, T rhs) noexcept |
| Mixed sum. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator+ (T lhs, ByteSize rhs) noexcept |
| Mixed sum. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator- (ByteSize lhs, T rhs) noexcept |
| Mixed difference. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator- (T lhs, ByteSize rhs) noexcept |
| Mixed difference. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator* (ByteSize lhs, T rhs) noexcept |
| Mixed product. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator* (T lhs, ByteSize rhs) noexcept |
| Mixed product. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator/ (ByteSize lhs, T rhs) noexcept |
| Mixed quotient. | |
| template<Type::Integral T> | |
| constexpr ByteSize | operator% (ByteSize lhs, T rhs) noexcept |
| Mixed remainder. | |
Count of octets (uint64_t storage).
This is the byte-length type. Size is an abstract unit count. The value that crosses a DLL is always 64-bit unsigned.
Implicit conversion exists only to std::size_t (clamp to size_t::max). Every other integral destination is explicit and clamps to T::max. There is no operator bool and no Value().
On hosts where std::size_t is unsigned long or unsigned long long, that conversion is the implicit operator std::size_t. Those two names are not given a second extern template of operator T().
Area products (ByteSize * ByteSize) are deleted. Scaling by Size or by an integer is allowed and yields ByteSize.
Mixed comparison with any Type::Integral is a hidden friend so n == 5, 5u == n and ASSERT_EQUAL are not ambiguous with the built-in candidates. Comparison with Size is also a hidden friend and compares the numeric counts.
1 * KiB uses the free StormByte::KiB constant (a ByteSize of 1024 octets). ByteSize::KiB(n) is the same scale via Unit.
Overflow of uint64_t and a negative result: assert when assertions are on; wrap modulo 2⁶⁴ when they are not. Division by zero: assert when assertions are on; undefined otherwise.
operator CString / operator WCString print an IEC human-readable length (1.50 KiB). B/KiB/MiB/GiB/TiB/PiB/EiB are IEC. KB/MB/GB/TB/PB/EB are SI (10³).
|
inlineconstexprnoexcept |
Zero octets.
|
inlineconstexprnoexcept |
From an integer octet count.
| T | Integral type. |
| value | Octets. Negative is undefined (assert when on). |
|
inlineexplicitconstexprnoexcept |
From an abstract unit count interpreted as octets.
| count | Unit count used as an octet count. |
|
constexprdefaultnoexcept |
Copy constructor.
| other | Length to copy. |
|
constexprdefaultnoexcept |
Move constructor.
| other | Length to take. |
|
constexprdefaultnoexcept |
Destructor.
|
explicitnoexcept |
IEC human-readable text owned by Base.
|
inlineconstexprnoexcept |
Implicit host size_t (clamped).
std::size_t.
|
inline |
IEC human-readable text on the caller heap.
|
inlineexplicitconstexprnoexcept |
Explicit conversion to an integral other than std::size_t.
| T | Integral type, not std::size_t. |
std::numeric_limits<T>::max().
|
explicitnoexcept |
IEC human-readable wide text owned by Base.
Remainder with a unit count.
| other | Divisor. |
*this.
|
inlineconstexprnoexcept |
Remainder with an integer.
| T | Integral type. |
| value | Divisor. |
*this. Scale by a unit count.
| other | Factor. |
*this.
|
inlineconstexprnoexcept |
Scale by an integer.
| T | Integral type. |
| value | Factor. |
*this.
|
inlineconstexprnoexcept |
Prefix increment.
*this after adding one octet.
|
inlineconstexprnoexcept |
Postfix increment.
Add other octets.
| other | Addend. |
*this.
|
inlineconstexprnoexcept |
Add an integer octet count.
| T | Integral type. |
| value | Addend. |
*this.
|
inlineconstexprnoexcept |
Prefix decrement.
*this after subtracting one octet.
|
inlineconstexprnoexcept |
Postfix decrement.
Subtract other octets.
| other | Subtrahend. |
*this.
|
inlineconstexprnoexcept |
Subtract an integer octet count.
| T | Integral type. |
| value | Subtrahend. |
*this. Divide by a unit count.
| other | Divisor. |
*this.
|
inlineconstexprnoexcept |
Divide by an integer.
| T | Integral type. |
| value | Divisor. |
*this. Move assignment.
| other | Length to take. |
*this.
|
constexprdefaultnoexcept |
Copy assignment.
| other | Length to copy. |
*this.
|
inlineconstexprnoexcept |
Assign an integer octet count.
| T | Integral type. |
| value | Octets. Negative is undefined (assert when on). |
*this. Mixed remainder.
| T | Integral type. |
| T | Integral type. |
| lhs | Dividend. |
| rhs | Divisor. |
Mixed product.
| T | Integral type. |
| T | Integral type. |
| lhs | Left factor. |
| rhs | Right factor. |
Mixed product.
| T | Integral type. |
| T | Integral type. |
| lhs | Left factor. |
| rhs | Right factor. |
Mixed sum.
| T | Integral type. |
| T | Integral type. |
| lhs | Left addend. |
| rhs | Right addend. |
Mixed sum.
| T | Integral type. |
| T | Integral type. |
| lhs | Left addend. |
| rhs | Right addend. |
Mixed difference.
| T | Integral type. |
| T | Integral type. |
| lhs | Minuend. |
| rhs | Subtrahend. |
Mixed difference.
| T | Integral type. |
| T | Integral type. |
| lhs | Minuend. |
| rhs | Subtrahend. |
Mixed quotient.
| T | Integral type. |
| T | Integral type. |
| lhs | Dividend. |
| rhs | Divisor. |
Numeric order.
| lhs | Left length. |
| rhs | Right length. |
|
friend |
Mixed order with an integer.
| T | Integral type. |
| T | Integral type. |
| lhs | Left length. |
| rhs | Right integer. |
|
friend |
Mixed order with an integer.
| T | Integral type. |
| T | Integral type. |
| lhs | Left integer. |
| rhs | Right length. |
Numeric equality.
| lhs | Left length. |
| rhs | Right length. |
Mixed equality with Size.
| lhs | Left length. |
| rhs | Right unit count. |
|
friend |
Mixed equality with an integer.
| T | Integral type. |
| T | Integral type. |
| lhs | Left length. |
| rhs | Right integer. |
Mixed equality with Size.
| lhs | Left unit count. |
| rhs | Right length. |
|
friend |
Mixed equality with an integer.
| T | Integral type. |
| T | Integral type. |
| lhs | Left integer. |
| rhs | Right length. |
|
staticconstexpr |
2^0 octets
|
staticconstexpr |
10^18 octets
|
staticconstexpr |
2^60 octets
|
staticconstexpr |
10^9 octets
|
staticconstexpr |
2^30 octets
|
staticconstexpr |
10^3 octets
|
staticconstexpr |
2^10 octets
|
staticconstexpr |
10^6 octets
|
staticconstexpr |
2^20 octets
|
staticconstexpr |
10^15 octets
|
staticconstexpr |
2^50 octets
|
staticconstexpr |
10^12 octets
|
staticconstexpr |
2^40 octets