|
Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
|
An amount of a quantity — offset-free (no datum). More...
#include <kind.h>
Public Types | |
| using | unit_type = U |
| using | underlying_type = typename traits::unit_traits<U>::underlying_type |
| < the wrapped unit type | |
Public Member Functions | |
| constexpr | delta () noexcept=default |
| < the wrapped unit's numeric type | |
| constexpr | delta (const U &amount) noexcept |
| constexpr | delta (underlying_type value) noexcept |
| Construct an amount directly from its underlying numeric value (in U's own unit). | |
| constexpr auto | value () const noexcept |
| The amount's numeric value in its own unit. | |
| constexpr auto | raw () const noexcept |
| The amount's raw (linearized) value. | |
| constexpr auto | to_linearized () const noexcept |
| The amount's linearized value (as the wrapped unit's to_linearized()). | |
| constexpr const char * | name () const noexcept |
| The wrapped unit's name/abbreviation (an amount does not rename the unit). | |
| constexpr const char * | abbreviation () const noexcept |
| template<ArithmeticType Arithmetic> | |
| constexpr Arithmetic | to () const noexcept |
| Express this amount's value as a plain arithmetic type — the numeric value in its own unit, matching the wrapped unit's to<Arithmetic>(). | |
| template<UnitType PlainTarget> requires traits::is_same_dimension_unit_v<U, PlainTarget> | |
| constexpr PlainTarget | to () const noexcept |
| Express this amount as a PLAIN unit of the same dimension — unwraps, SCALE ONLY (the datum is never applied): a 10 degC delta is an 18 degF delta, never an absolute 50 degF. | |
| template<DeltaType WrapperTarget> requires traits::is_same_dimension_unit_v<U, typename WrapperTarget::unit_type> | |
| constexpr WrapperTarget | to () const noexcept |
| Express this amount as another delta<V> — stays an amount (scale-only). | |
An amount of a quantity — offset-free (no datum).
| U | the wrapped unit type (its datum is ignored; only its scale matters). |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Express this amount as a PLAIN unit of the same dimension — unwraps, SCALE ONLY (the datum is never applied): a 10 degC delta is an 18 degF delta, never an absolute 50 degF.
.to<celsius<double>>() is the plain wrapped amount. A conversion into a coarser integer unit (that would truncate) is rejected with a clear message rather than template-substitution spew; convert to a floating-point delta first if the truncation is intended.