Small utility header for human-formatted input and output of file sizes in bytes:
5.55k,5.55 k,5.55kB,5.55 kiBto number of bytes- available case-sensitive prefixes are
k,M,G,T,P(decimal) andki,Mi,Gi,Ti,Pi(binary) - throws exceptions for invalid inputs
- formats to 3-digit precision with affixed decimal units (e.g.
5.55 kB) - defined
operator<<for iostream output - defines c++ literals in
bytesize::literalsnamespace
- to parse a
std::string, usebytesize::bytesize::parsestatic method - to output, use
bytesize::bytesize::format - output to
std::ostreamviaoperator<< - output to fmt with
{}automatically — useBYTESIZE_FMTLIB_FORMATTERto declare the tempate (fmt/fmt.hmust be included before that) using namespace bytesize::literalsto do things like5.55_kBin your source