dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
format.hpp File Reference

std::formatter specializations for UnitValue, MeasureValue, ranges, and descriptors. More...

#include <dimval/core.hpp>
#include <dimval/descriptor.hpp>
#include <dimval/measure.hpp>
#include <dimval/range.hpp>
#include <dimval/traits.hpp>
#include <dimval/unit.hpp>
#include <cstddef>
#include <cstdint>
#include <format>
#include <string>
#include <string_view>
Include dependency graph for format.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

std::formatter specializations for UnitValue, MeasureValue, ranges, and descriptors.

Supported format spec grammar:

[style][.precision]

where style is one of: "" (default), "short", "full", "json".

Examples:

std::format("{}",        v)   // 42.5 m
std::format("{:short}",  v)   // 42.5m
std::format("{:full}",   v)   // 42.5 meter
std::format("{:json}",   v)   // {"unit":"m","value":42.5}
std::format("{:.2}",     v)   // 42.50 m
std::format("{:full.3}", v)   // 42.500 meter