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

Concepts and helper accessors that drive the static side of dimval. More...

#include <dimval/base.hpp>
#include <dimval/descriptor.hpp>
#include <type_traits>
Include dependency graph for traits.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Concepts

concept  dimval::UnitLike
 Concept satisfied by any struct that inherits from UnitBase.
 
concept  dimval::MeasureLike
 Concept satisfied by any struct that inherits from MeasureBase.
 

Functions

template<UnitLike U>
constexpr UnitDescriptor dimval::unit_descriptor_of () noexcept
 Convenience accessor: descriptor of a unit struct.
 
template<MeasureLike M>
constexpr MeasureDescriptor dimval::measure_descriptor_of () noexcept
 Convenience accessor: descriptor of a measure struct.
 
template<UnitLike A, UnitLike B>
constexpr bool dimval::units_compatible () noexcept
 True iff two unit structs share the same kind (and therefore convert).
 
template<MeasureLike M, UnitLike U>
constexpr bool dimval::measure_uses_unit () noexcept
 True iff a measure's base unit is the given unit.
 

Detailed Description

Concepts and helper accessors that drive the static side of dimval.

Every unit/measure is a struct that derives from UnitBase / MeasureBase (see <dimval/base.hpp>) and publishes its metadata as static constexpr members. The concepts below detect that derivation; the helpers forward to each struct's own descriptor() for source compatibility.