qxLib
List of all members
qx::unit< T, unit_t > Struct Template Reference

#include <base.h>

Detailed Description

template<arithmetic_c T, enumeration_c unit_t>
struct qx::unit< T, unit_t >

// The things you can do with `qx::unit`:
// 1. Convert it using `qx::convert`:
qx::unit result = qx::convert(unit).to(qx::units::unit_type::type2);
// 2. Format it:
qx::string = qx::string::static_format(QX_TEXT("{}"), unit); // -> for ex. 20kB
// 3. Create it from a string:
std::optional<qx::unit<int, qx::units::data>> optResult =
qx::unit_from_string<int, qx::units::data, qx::char_type>(QX_TEXT("20KiB"));
// 4. Get the nearest meaningful value (SI units):
// 2000B -> 1.95KiB
// 3000B -> 2.92KiB
qx::unit converted1 = qx::normalize_unit(unit);
unit< T, unit_t > normalize_unit(unit< T, unit_t > unit) noexcept
The function returns the closest value greater than one from the SI for the unit of measurement.
requires static format_acceptable_args_c< char_type, args_t... > basic_string static_format(const format_string_type< std::type_identity_t< args_t >... > sFormat, args_t &&... args)
Create a string by formatting it with the format string and the args.
A conversion class.
Definition: base.h:62
Definition: base.h:38
Template Parameters
T- floating point or integral type
unit_t- unit type enum

Definition at line 37 of file base.h.


The documentation for this struct was generated from the following files: