WPILibC++ 2023.4.3-108-ge5452e3
units::unit< Conversion, BaseUnit, PiExponent, Translation > Struct Template Reference

Type representing an arbitrary unit. More...

#include <units/base.h>

Inheritance diagram for units::unit< Conversion, BaseUnit, PiExponent, Translation >:

Public Types

typedef units::traits::unit_traits< BaseUnit >::base_unit_type base_unit_type
 
typedef std::ratio_multiply< typename BaseUnit::conversion_ratio, Conversion > conversion_ratio
 
typedef std::ratio_add< typename BaseUnit::pi_exponent_ratio, PiExponent > pi_exponent_ratio
 
typedef std::ratio_add< std::ratio_multiply< typename BaseUnit::conversion_ratio, Translation >, typename BaseUnit::translation_ratio > translation_ratio
 

Detailed Description

template<class Conversion, class BaseUnit, class PiExponent = std::ratio<0>, class Translation = std::ratio<0>>
struct units::unit< Conversion, BaseUnit, PiExponent, Translation >

Type representing an arbitrary unit.

unit types are used as tags for the conversion function. They are not containers (see unit_t for a container class). Each unit is defined by:

  • A std::ratio defining the conversion factor to the base unit type. (e.g. std::ratio<1,12> for inches to feet)
  • A base unit that the unit is derived from (or a unit category. Must be of type unit or base_unit)
  • An exponent representing factors of PI required by the conversion. (e.g. std::ratio<-1> for a radians to degrees conversion)
  • a ratio representing a datum translation required for the conversion (e.g. std::ratio<32> for a fahrenheit to celsius conversion)

Typically, a specific unit, like meters, would be implemented as a type alias of unit, i.e. using meters = unit<std::ratio<1>, units::category::length_unit, or using inches = unit<std::ratio<1,12>, feet>.

Template Parameters
Conversionstd::ratio representing scalar multiplication factor.
BaseUnitUnit type which this unit is derived from. May be a base_unit, or another unit.
PiExponentstd::ratio representing the exponent of pi required by the conversion.
Translationstd::ratio representing any datum translation required by the conversion.

Member Typedef Documentation

◆ base_unit_type

template<class Conversion , class BaseUnit , class PiExponent = std::ratio<0>, class Translation = std::ratio<0>>
typedef units::traits::unit_traits<BaseUnit>::base_unit_type units::unit< Conversion, BaseUnit, PiExponent, Translation >::base_unit_type

◆ conversion_ratio

template<class Conversion , class BaseUnit , class PiExponent = std::ratio<0>, class Translation = std::ratio<0>>
typedef std::ratio_multiply<typename BaseUnit::conversion_ratio, Conversion> units::unit< Conversion, BaseUnit, PiExponent, Translation >::conversion_ratio

◆ pi_exponent_ratio

template<class Conversion , class BaseUnit , class PiExponent = std::ratio<0>, class Translation = std::ratio<0>>
typedef std::ratio_add<typename BaseUnit::pi_exponent_ratio, PiExponent> units::unit< Conversion, BaseUnit, PiExponent, Translation >::pi_exponent_ratio

◆ translation_ratio

template<class Conversion , class BaseUnit , class PiExponent = std::ratio<0>, class Translation = std::ratio<0>>
typedef std::ratio_add<std::ratio_multiply<typename BaseUnit::conversion_ratio, Translation>, typename BaseUnit::translation_ratio> units::unit< Conversion, BaseUnit, PiExponent, Translation >::translation_ratio

The documentation for this struct was generated from the following file: