Typedefs
util::quantities::prefixes Namespace Reference

Definitions of additional prefixes. More...

Typedefs

using kibi = std::ratio<(1LL<< 10)>
 Factor 1'024 (2^10). More...
 
using mebi = std::ratio<(1LL<< 20)>
 Factor 1'048'576 (2^20). More...
 
using gibi = std::ratio<(1LL<< 30)>
 Factor 1'073'741'824 (2^30). More...
 
using tebi = std::ratio<(1LL<< 40)>
 Factor 2^40. More...
 
using pebi = std::ratio<(1LL<< 50)>
 Factor 2^50. More...
 
using exbi = std::ratio<(1LL<< 60)>
 Factor 2^60. More...
 

Detailed Description

Definitions of additional prefixes.

Quantities are based on scaled units, which are units with a scaling factor.

Prefixes describe these scaling factors, as a rational number represented via a fraction. In this library, prefix objects must expose the same interface as std::ratio template.

The standard ratio classes defined in C++ (e.g. std::milli, std::giga) provide most of the needed prefixes. In this namespace, custom prefixes can be defined.

A prefix can be associated with its own symbol. In that case, the prefix should specialize the template util::quantites::concepts::Prefix and provide:

For example, this prefix should work like 1'000, but has its own symbol:

struct grant: public std::ratio<1000> {};
template <>
struct Prefix<grant> {
/// Returns the symbol of the prefix.
static constexpr auto symbol() { return "k"sv; }
/// Returns the full name of the prefix.
static constexpr auto name() { return "grant"sv; }
}; // struct Prefix<grant>
} // namespace util::quantities::prefixes

Note however that the current implementation tends to bring back to std::ratio. Also note that defining an alias, like in using grant = std::ratio<1000>, is not enough to allow for a different symbol.

The namespace also imports the prefixes from C++ standard library for convenience.

Typedef Documentation

using util::quantities::prefixes::exbi = typedef std::ratio<(1LL << 60)>

Factor 2^60.

Definition at line 59 of file datasize.h.

using util::quantities::prefixes::gibi = typedef std::ratio<(1LL << 30)>

Factor 1'073'741'824 (2^30).

Definition at line 50 of file datasize.h.

using util::quantities::prefixes::kibi = typedef std::ratio<(1LL << 10)>

Factor 1'024 (2^10).

Definition at line 44 of file datasize.h.

using util::quantities::prefixes::mebi = typedef std::ratio<(1LL << 20)>

Factor 1'048'576 (2^20).

Definition at line 47 of file datasize.h.

using util::quantities::prefixes::pebi = typedef std::ratio<(1LL << 50)>

Factor 2^50.

Definition at line 56 of file datasize.h.

using util::quantities::prefixes::tebi = typedef std::ratio<(1LL << 40)>

Factor 2^40.

Definition at line 53 of file datasize.h.