FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
Binary Unit Literal Operators

User-defined literals for binary (base-2) memory units. More...

Functions

constexpr decltype(auto) operator""_kib (unsigned long long value) noexcept
 User-defined literal operator for kibibytes (KiB)
 
constexpr decltype(auto) operator""_mib (unsigned long long value) noexcept
 User-defined literal operator for mebibytes (MiB)
 

Detailed Description

User-defined literals for binary (base-2) memory units.

These operators provide convenient syntax for expressing memory sizes using binary units (powers of 1024) rather than decimal units (powers of 1000).

Function Documentation

◆ operator""_kib()

decltype(auto) operator""_kib ( unsigned long long value)
inlineconstexprnoexcept

User-defined literal operator for kibibytes (KiB)

Converts a numeric literal to bytes by multiplying by 1024 (2^10). A kibibyte is 1024 bytes, following the IEC 60027-2 standard for binary prefixes.

Parameters
valueThe numeric value in kibibytes
Returns
unsigned long long The equivalent value in bytes
Note
This operator is constexpr, allowing compile-time evaluation
Uses bit shifting (1 << 10) for efficiency instead of multiplication

Definition at line 92 of file common.hpp.

◆ operator""_mib()

decltype(auto) operator""_mib ( unsigned long long value)
inlineconstexprnoexcept

User-defined literal operator for mebibytes (MiB)

Converts a numeric literal to bytes by multiplying by 1,048,576 (2^20). A mebibyte is 1,048,576 bytes (1024 * 1024), following the IEC 60027-2 standard.

Parameters
valueThe numeric value in mebibytes
Returns
unsigned long long The equivalent value in bytes
Note
This operator is constexpr, allowing compile-time evaluation
Uses bit shifting (1 << 20) for efficiency instead of multiplication

Definition at line 109 of file common.hpp.