WPILibC++ 2023.4.3-108-ge5452e3
Unit Manipulators

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

Typedefs

template<class U >
using units::inverse = typename units::detail::inverse_impl< U >::type
 represents the inverse unit type of class U. More...
 
template<class U >
using units::squared = typename units::detail::squared_impl< U >::type
 represents the unit type of class U squared More...
 
template<class U >
using units::cubed = typename units::detail::cubed_impl< U >::type
 represents the type of class U cubed. More...
 
template<class U , std::intmax_t Eps = 10000000000>
using units::square_root = typename units::detail::sqrt_impl< U, Eps >::type
 represents the square root of type class U. More...
 
template<class U >
using units::atto = typename units::detail::prefix< std::atto, U >::type
 Represents the type of class U with the metric 'atto' prefix appended. More...
 
template<class U >
using units::femto = typename units::detail::prefix< std::femto, U >::type
 Represents the type of class U with the metric 'femto' prefix appended. More...
 
template<class U >
using units::pico = typename units::detail::prefix< std::pico, U >::type
 Represents the type of class U with the metric 'pico' prefix appended. More...
 
template<class U >
using units::nano = typename units::detail::prefix< std::nano, U >::type
 Represents the type of class U with the metric 'nano' prefix appended. More...
 
template<class U >
using units::micro = typename units::detail::prefix< std::micro, U >::type
 Represents the type of class U with the metric 'micro' prefix appended. More...
 
template<class U >
using units::milli = typename units::detail::prefix< std::milli, U >::type
 Represents the type of class U with the metric 'milli' prefix appended. More...
 
template<class U >
using units::centi = typename units::detail::prefix< std::centi, U >::type
 Represents the type of class U with the metric 'centi' prefix appended. More...
 
template<class U >
using units::deci = typename units::detail::prefix< std::deci, U >::type
 Represents the type of class U with the metric 'deci' prefix appended. More...
 
template<class U >
using units::deca = typename units::detail::prefix< std::deca, U >::type
 Represents the type of class U with the metric 'deca' prefix appended. More...
 
template<class U >
using units::hecto = typename units::detail::prefix< std::hecto, U >::type
 Represents the type of class U with the metric 'hecto' prefix appended. More...
 
template<class U >
using units::kilo = typename units::detail::prefix< std::kilo, U >::type
 Represents the type of class U with the metric 'kilo' prefix appended. More...
 
template<class U >
using units::mega = typename units::detail::prefix< std::mega, U >::type
 Represents the type of class U with the metric 'mega' prefix appended. More...
 
template<class U >
using units::giga = typename units::detail::prefix< std::giga, U >::type
 Represents the type of class U with the metric 'giga' prefix appended. More...
 
template<class U >
using units::tera = typename units::detail::prefix< std::tera, U >::type
 Represents the type of class U with the metric 'tera' prefix appended. More...
 
template<class U >
using units::peta = typename units::detail::prefix< std::peta, U >::type
 Represents the type of class U with the metric 'peta' prefix appended. More...
 
template<class U >
using units::exa = typename units::detail::prefix< std::exa, U >::type
 Represents the type of class U with the metric 'exa' prefix appended. More...
 
template<class U >
using units::kibi = typename units::detail::prefix< std::ratio< 1024 >, U >::type
 Represents the type of class U with the binary 'kibi' prefix appended. More...
 
template<class U >
using units::mebi = typename units::detail::prefix< std::ratio< 1048576 >, U >::type
 Represents the type of class U with the binary 'mibi' prefix appended. More...
 
template<class U >
using units::gibi = typename units::detail::prefix< std::ratio< 1073741824 >, U >::type
 Represents the type of class U with the binary 'gibi' prefix appended. More...
 
template<class U >
using units::tebi = typename units::detail::prefix< std::ratio< 1099511627776 >, U >::type
 Represents the type of class U with the binary 'tebi' prefix appended. More...
 
template<class U >
using units::pebi = typename units::detail::prefix< std::ratio< 1125899906842624 >, U >::type
 Represents the type of class U with the binary 'pebi' prefix appended. More...
 
template<class U >
using units::exbi = typename units::detail::prefix< std::ratio< 1152921504606846976 >, U >::type
 Represents the type of class U with the binary 'exbi' prefix appended. More...
 

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

◆ atto

template<class U >
using units::atto = typedef typename units::detail::prefix<std::atto, U>::type

Represents the type of class U with the metric 'atto' prefix appended.

E.g. atto<meters> represents meters*10^-18

Template Parameters
Uunit type to apply the prefix to.

◆ centi

template<class U >
using units::centi = typedef typename units::detail::prefix<std::centi,U>::type

Represents the type of class U with the metric 'centi' prefix appended.

E.g. centi<meters> represents meters*10^-2

Template Parameters
Uunit type to apply the prefix to.

◆ cubed

template<class U >
using units::cubed = typedef typename units::detail::cubed_impl<U>::type

represents the type of class U cubed.

Template Parameters
Uunit type to cube.

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

◆ deca

template<class U >
using units::deca = typedef typename units::detail::prefix<std::deca, U>::type

Represents the type of class U with the metric 'deca' prefix appended.

E.g. deca<meters> represents meters*10^1

Template Parameters
Uunit type to apply the prefix to.

◆ deci

template<class U >
using units::deci = typedef typename units::detail::prefix<std::deci, U>::type

Represents the type of class U with the metric 'deci' prefix appended.

E.g. deci<meters> represents meters*10^-1

Template Parameters
Uunit type to apply the prefix to.

◆ exa

template<class U >
using units::exa = typedef typename units::detail::prefix<std::exa, U>::type

Represents the type of class U with the metric 'exa' prefix appended.

E.g. exa<meters> represents meters*10^18

Template Parameters
Uunit type to apply the prefix to.

◆ exbi

template<class U >
using units::exbi = typedef typename units::detail::prefix<std::ratio<1152921504606846976>, U>::type

Represents the type of class U with the binary 'exbi' prefix appended.

E.g. exbi<bytes> represents bytes*2^60

Template Parameters
Uunit type to apply the prefix to.

◆ femto

template<class U >
using units::femto = typedef typename units::detail::prefix<std::femto,U>::type

Represents the type of class U with the metric 'femto' prefix appended.

E.g. femto<meters> represents meters*10^-15

Template Parameters
Uunit type to apply the prefix to.

◆ gibi

template<class U >
using units::gibi = typedef typename units::detail::prefix<std::ratio<1073741824>, U>::type

Represents the type of class U with the binary 'gibi' prefix appended.

E.g. gibi<bytes> represents bytes*2^30

Template Parameters
Uunit type to apply the prefix to.

◆ giga

template<class U >
using units::giga = typedef typename units::detail::prefix<std::giga, U>::type

Represents the type of class U with the metric 'giga' prefix appended.

E.g. giga<meters> represents meters*10^9

Template Parameters
Uunit type to apply the prefix to.

◆ hecto

template<class U >
using units::hecto = typedef typename units::detail::prefix<std::hecto,U>::type

Represents the type of class U with the metric 'hecto' prefix appended.

E.g. hecto<meters> represents meters*10^2

Template Parameters
Uunit type to apply the prefix to.

◆ inverse

template<class U >
using units::inverse = typedef typename units::detail::inverse_impl<U>::type

represents the inverse unit type of class U.

Template Parameters
Uunit type to invert.

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

◆ kibi

template<class U >
using units::kibi = typedef typename units::detail::prefix<std::ratio<1024>, U>::type

Represents the type of class U with the binary 'kibi' prefix appended.

E.g. kibi<bytes> represents bytes*2^10

Template Parameters
Uunit type to apply the prefix to.

◆ kilo

template<class U >
using units::kilo = typedef typename units::detail::prefix<std::kilo, U>::type

Represents the type of class U with the metric 'kilo' prefix appended.

E.g. kilo<meters> represents meters*10^3

Template Parameters
Uunit type to apply the prefix to.

◆ mebi

template<class U >
using units::mebi = typedef typename units::detail::prefix<std::ratio<1048576>, U>::type

Represents the type of class U with the binary 'mibi' prefix appended.

E.g. mebi<bytes> represents bytes*2^20

Template Parameters
Uunit type to apply the prefix to.

◆ mega

template<class U >
using units::mega = typedef typename units::detail::prefix<std::mega, U>::type

Represents the type of class U with the metric 'mega' prefix appended.

E.g. mega<meters> represents meters*10^6

Template Parameters
Uunit type to apply the prefix to.

◆ micro

template<class U >
using units::micro = typedef typename units::detail::prefix<std::micro,U>::type

Represents the type of class U with the metric 'micro' prefix appended.

E.g. micro<meters> represents meters*10^-6

Template Parameters
Uunit type to apply the prefix to.

◆ milli

template<class U >
using units::milli = typedef typename units::detail::prefix<std::milli,U>::type

Represents the type of class U with the metric 'milli' prefix appended.

E.g. milli<meters> represents meters*10^-3

Template Parameters
Uunit type to apply the prefix to.

◆ nano

template<class U >
using units::nano = typedef typename units::detail::prefix<std::nano, U>::type

Represents the type of class U with the metric 'nano' prefix appended.

E.g. nano<meters> represents meters*10^-9

Template Parameters
Uunit type to apply the prefix to.

◆ pebi

template<class U >
using units::pebi = typedef typename units::detail::prefix<std::ratio<1125899906842624>, U>::type

Represents the type of class U with the binary 'pebi' prefix appended.

E.g. pebi<bytes> represents bytes*2^50

Template Parameters
Uunit type to apply the prefix to.

◆ peta

template<class U >
using units::peta = typedef typename units::detail::prefix<std::peta, U>::type

Represents the type of class U with the metric 'peta' prefix appended.

E.g. peta<meters> represents meters*10^15

Template Parameters
Uunit type to apply the prefix to.

◆ pico

template<class U >
using units::pico = typedef typename units::detail::prefix<std::pico, U>::type

Represents the type of class U with the metric 'pico' prefix appended.

E.g. pico<meters> represents meters*10^-12

Template Parameters
Uunit type to apply the prefix to.

◆ square_root

template<class U , std::intmax_t Eps = 10000000000>
using units::square_root = typedef typename units::detail::sqrt_impl<U, 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
Uunit 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, squared<sqrt<meter>> != meter, i.e. the operation is not reversible, and it will result in propagated approximations. Use only when absolutely necessary.

◆ squared

template<class U >
using units::squared = typedef typename units::detail::squared_impl<U>::type

represents the unit type of class U squared

Template Parameters
Uunit type to square.

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

◆ tebi

template<class U >
using units::tebi = typedef typename units::detail::prefix<std::ratio<1099511627776>, U>::type

Represents the type of class U with the binary 'tebi' prefix appended.

E.g. tebi<bytes> represents bytes*2^40

Template Parameters
Uunit type to apply the prefix to.

◆ tera

template<class U >
using units::tera = typedef typename units::detail::prefix<std::tera, U>::type

Represents the type of class U with the metric 'tera' prefix appended.

E.g. tera<meters> represents meters*10^12

Template Parameters
Uunit type to apply the prefix to.