|
dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
|
A value carrying both a measure tag and a unit tag. More...
#include <measure.hpp>


Public Member Functions | |
| constexpr | MeasureValue (T value) noexcept |
Implicit conversion from the numeric type — enables DistanceValue d = 1500.0; style construction. | |
| constexpr UnitValue< unit_t, T > | as_unit_value () const noexcept |
| Drop the measure tag and expose the underlying UnitValue. | |
| MeasureDescriptor | descriptor () const noexcept override |
Measure descriptor — read fields like descriptor().name from here. | |
| UnitDescriptor | unit_descriptor () const noexcept override |
Underlying unit's descriptor — read unit_descriptor().id, .symbol, etc. | |
Static Public Member Functions | |
| static std::shared_ptr< MeasureValue > | of (T value) |
Heap-allocated shared-owned factory: auto d = DistanceValue::of(1500.0); For a stack value, just construct directly (DistanceValue d = 1500.0). | |
| static std::unique_ptr< MeasureValue > | unique (T value) |
| Heap-allocated unique-owned factory. | |
| static std::expected< MeasureValue, ParseError > | parse (std::string_view input) |
| Parse "100 m" → MeasureValue<M,T>. Forwards to UnitValue<base_unit_t,T>::parse. | |
A value carrying both a measure tag and a unit tag.
The measure refines the meaning of a value beyond its physical unit. For example, Distance and Length are both stored in meters but have distinct semantics. The measure's base unit is fixed at the type level.
| M | a measure struct that derives from MeasureBase. |
| T | a numeric type. Defaults to double. |
|
inlineconstexprnoexcept |
Implicit conversion from the numeric type — enables DistanceValue d = 1500.0; style construction.
Safe because the measure tag type already prevents cross-measure assignments.