dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
ostream.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <dimval/format.hpp>
7#include <dimval/measure.hpp>
8#include <dimval/range.hpp>
9#include <dimval/traits.hpp>
10#include <dimval/unit.hpp>
11
12#include <format>
13#include <ostream>
14
15namespace dimval {
16
17template <UnitLike U, NumericValue T>
18inline std::ostream& operator<<(std::ostream& os, const UnitValue<U, T>& v) {
19 return os << std::format("{}", v);
20}
21
22template <MeasureLike M, NumericValue T>
23inline std::ostream& operator<<(std::ostream& os, const MeasureValue<M, T>& v) {
24 return os << std::format("{}", v);
25}
26
27template <UnitLike U, NumericValue T>
28inline std::ostream& operator<<(std::ostream& os, const UnitRangeValue<U, T>& r) {
29 return os << std::format("{}", r);
30}
31
32template <MeasureLike M, NumericValue T>
33inline std::ostream& operator<<(std::ostream& os, const MeasureRangeValue<M, T>& r) {
34 return os << std::format("{}", r);
35}
36
37inline std::ostream& operator<<(std::ostream& os, const UnitDescriptor& d) {
38 return os << std::format("{}", d);
39}
40
41inline std::ostream& operator<<(std::ostream& os, const MeasureDescriptor& d) {
42 return os << std::format("{}", d);
43}
44
45} // namespace dimval
std::formatter specializations for UnitValue, MeasureValue, ranges, and descriptors.
MeasureValue<M,T>: a UnitValue tagged with an additional semantic measure.
UnitRangeValue and MeasureRangeValue — closed/open intervals of dimensional values.
Concepts and helper accessors that drive the static side of dimval.
UnitValue<U,T>: a strongly-typed value carrying a compile-time unit tag.