28template <UnitLike U, NumericValue T =
double>
35template <MeasureLike M, NumericValue T =
double>
36[[nodiscard]] std::expected<MeasureValue<M, T>, ParseError>
44[[nodiscard]]
inline std::expected<DynamicUnitValue, ParseError>
46 auto split = detail::split_number_and_tail(input);
48 return std::unexpected{split.error()};
50 auto num = detail::parse_number<double>(split->number, input);
52 return std::unexpected{num.error()};
54 if (split->tail.empty()) {
58 return std::unexpected{
62 "no symbol given and 'dimensionless' is not registered"}};
68 return std::unexpected{
72 std::string{
"unknown unit symbol: "} + std::string{split->tail}}};
const UnitDescriptor * find(const std::string_view id_or_symbol) const
Look up by id, then by symbol. Returns nullptr if not found.
Definition registry.hpp:62
static UnitRegistry & global()
Process-wide singleton.
Definition registry.hpp:36
Common concepts, error types, and small utilities used across dimval.
MeasureValue<M,T>: a UnitValue tagged with an additional semantic measure.
std::expected< DynamicUnitValue, ParseError > parse_dynamic_unit_value(std::string_view input)
Parse a string of the form "42.5 m" against the runtime registry.
Definition parse.hpp:45
std::expected< MeasureValue< M, T >, ParseError > parse_measure_value(std::string_view input)
Parse a string of the form "42.5 m" into a MeasureValue<M,T>.
Definition parse.hpp:37
std::expected< UnitValue< U, T >, ParseError > parse_unit_value(std::string_view input)
Parse a string of the form "42.5 m" into a UnitValue<U,T>.
Definition parse.hpp:29
Low-level parsing primitives shared by parse.hpp and the inline UnitValue::parse / MeasureValue::pars...
Thread-safe runtime registries of unit and measure descriptors.
Type-erased dynamic parse result.
Definition parse.hpp:21
static std::expected< MeasureValue, ParseError > parse(std::string_view input)
Parse "100 m" → MeasureValue<M,T>. Forwards to UnitValue<base_unit_t,T>::parse.
Definition measure.hpp:56
Detailed error report from a parse_*_value call.
Definition core.hpp:30
Runtime metadata for a unit.
Definition descriptor.hpp:29
static std::expected< UnitValue, ParseError > parse(const std::string_view input)
Parse "42.5 m" → UnitValue<U,T>.
Definition unit.hpp:62
Concepts and helper accessors that drive the static side of dimval.
UnitValue<U,T>: a strongly-typed value carrying a compile-time unit tag.