|
Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
|
Defines a series of classes to obtain unit type information at compile-time. More...
Namespaces | |
| namespace | units::traits |
| namespace representing type traits which can access the properties of types provided by the units library. | |
Classes | |
| struct | units::traits::is_unit< T > |
| Traits which tests if a class is a unit. More... | |
| struct | units::traits::strong< T > |
| SFINAE-able trait that maps a conversion_factor to its strengthened type. More... | |
| struct | units::traits::replace_underlying< class, class > |
| SFINAE-able trait which replaces the underlying type of Unit with Underlying. More... | |
| struct | units::traits::is_same_dimension_conversion_factor< Cf1, Cf2 > |
| BinaryTypeTrait for querying whether Cf1 and Cf2 are conversion factors to the same dimension. More... | |
| struct | units::traits::is_same_dimension_unit< U1, U2 > |
| BinaryTypeTrait for querying whether U1 and U2 are units of the same dimension. More... | |
| struct | units::traits::has_linear_scale< T > |
| Trait which tests whether a type is inherited from a linear scale. More... | |
| struct | units::traits::has_decibel_scale< T > |
| Trait which tests whether a type is inherited from a decibel scale. More... | |
| struct | units::traits::is_absolute< T > |
| Trait which tests whether T is an absolute<U> point wrapper. More... | |
| struct | units::traits::is_delta< T > |
| Trait which tests whether T is a delta<U> amount wrapper. More... | |
| struct | units::traits::is_kind< T > |
| Trait which tests whether T is a string-tagged kind<Tag, U>. More... | |
Typedefs | |
| template<class T, class Ret> | |
| using | units::traits::is_numerical_scale = std::is_invocable_r<Ret, detail::invocable_scale<T>, Ret> |
| Trait which tests whether T meets the requirements for a numerical scale. | |
| template<RatioType Ratio, std::intmax_t Eps = 10000000000> | |
| using | units::ratio_sqrt = typename units::detail::Sqrt<Ratio, std::ratio<1, Eps>>::type |
| Calculate square root of a ratio at compile-time. | |
Defines a series of classes to obtain unit type information at compile-time.
| using units::traits::is_numerical_scale = std::is_invocable_r<Ret, detail::invocable_scale<T>, Ret> |
Trait which tests whether T meets the requirements for a numerical scale.
A numerical scale must have static member functions named linearize and scale that take one Ret argument and return a Ret value, where linearize returns the linearized input value and scale returns the scaled input value.
Numerical scales are used by units::unit to linearize and scale values if they represent things like dB.
| using units::ratio_sqrt = typename units::detail::Sqrt<Ratio, std::ratio<1, Eps>>::type |
Calculate square root of a ratio at compile-time.
Calculates a rational approximation of the square root of the ratio. The error in the calculation is bounded by 1/epsilon (Eps). E.g. for the default value of 10000000000, the maximum error will be a/10000000000, or 1e-8, or said another way, the error will be on the order of 10^-9. Since these calculations are done at compile time, it is advisable to set epsilon to the highest value that does not cause an integer overflow in the calculation. If you can't compile ratio_sqrt due to overflow errors, reducing the value of epsilon sufficiently will correct the problem.
ratio_sqrt is guaranteed to converge for all values of Ratio which do not overflow.
| Ratio | ratio to take the square root of. This can represent any rational value, not just integers or values with integer roots. |
| Eps | Value of epsilon, which represents the inverse of the maximum allowable error. This value should be chosen to be as high as possible before integer overflow errors occur in the compiler. |