Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
Loading...
Searching...
No Matches
Unit Manipulators

Defines a series of classes used to manipulate unit types, such as inverse<>, squared<>, and metric prefixes. More...

Collaboration diagram for Unit Manipulators:

Topics

 Prefixes
 Defines the metric and binary prefix manipulators (e.g.

Typedefs

template<ConversionFactorType Cf>
using units::inverse = typename detail::inverse_impl<Cf>::type
 represents the inverse unit type of class U.
template<ConversionFactorType Cf>
using units::squared = typename detail::squared_impl<Cf>::type
 represents the unit type of class U squared
template<ConversionFactorType Cf>
using units::cubed = typename detail::cubed_impl<Cf>::type
 represents the type of class U cubed.
template<ConversionFactorType Cf, std::intmax_t Eps = 10000000000>
using units::square_root = typename detail::sqrt_impl<Cf, Eps>::type
 represents the square root of type class U.

Detailed Description

Defines a series of classes used to manipulate unit types, such as inverse<>, squared<>, and metric prefixes.

Unit manipulators can be chained together, e.g. inverse<squared<pico<time::seconds>>> to represent picoseconds^-2.

Typedef Documentation

◆ cubed

template<ConversionFactorType Cf>
using units::cubed = typename detail::cubed_impl<Cf>::type

represents the type of class U cubed.

Template Parameters
Cfunit type to cube.

E.g. cubed<meters> will represent meters^3.

◆ inverse

template<ConversionFactorType Cf>
using units::inverse = typename detail::inverse_impl<Cf>::type

represents the inverse unit type of class U.

Template Parameters
Cfunit type to invert.

E.g. inverse<meters> will represent meters^-1 (i.e. 1/meters).

◆ square_root

template<ConversionFactorType Cf, std::intmax_t Eps = 10000000000>
using units::square_root = typename detail::sqrt_impl<Cf, Eps>::type

represents the square root of type class U.

Calculates a rational approximation of the square root of the unit. 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.

Template Parameters
Cfunit type to take the square root of.
EpsValue 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.
Note
USE WITH CAUTION. The is an approximate value. In general, square<square_root<meter>> != meter, i.e. the operation is not reversible, and it will result in propagated approximations. Use only when absolutely necessary.

◆ squared

template<ConversionFactorType Cf>
using units::squared = typename detail::squared_impl<Cf>::type

represents the unit type of class U squared

Template Parameters
Cfunit type to square.

E.g. square<meters> will represent meters^2.