WPILibC++ 2023.4.3-108-ge5452e3
base.h File Reference
#include <chrono>
#include <ratio>
#include <type_traits>
#include <cstdint>
#include <cmath>
#include <limits>

Go to the source code of this file.

Classes

struct  units::traits::is_ratio< T >
 Trait that tests whether a type represents a std::ratio. More...
 
struct  units::traits::is_base_unit< T >
 Trait which tests if a class is a base_unit type. More...
 
struct  units::traits::is_unit< T >
 Traits which tests if a class is a unit More...
 
struct  units::base_unit< Meter, Kilogram, Second, Radian, Ampere, Kelvin, Mole, Candela, Byte >
 Class representing SI base unit types. More...
 
struct  units::unit< Conversion, BaseUnit, PiExponent, Translation >
 Type representing an arbitrary unit. More...
 
struct  units::traits::is_convertible_unit< U1, U2 >
 Trait which checks whether two units can be converted to each other. More...
 
struct  units::traits::is_nonlinear_scale< T, Ret >
 Trait which tests that class T meets the requirements for a non-linear scale. More...
 
struct  units::traits::is_convertible_unit_t< U1, U2 >
 Trait which tests whether two container types derived from unit_t are convertible to each other. More...
 
struct  units::traits::is_unit_t< T >
 Traits which tests if a class is a unit More...
 
class  units::unit_t< Units, T, NonLinearScale >
 Container for values which represent quantities of a given unit. 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_same_scale< T1, T2 >
 Trait which tests whether two types has the same non-linear scale. More...
 
struct  units::linear_scale< T >
 unit_t scale which is linear More...
 
struct  units::decibel_scale< T >
 unit_t scale for representing decibel values. More...
 
struct  units::unit_value_t< Units, Num, Denom >
 Stores a rational unit value as a compile-time constant. More...
 
struct  units::traits::is_unit_value_t< T, Units >
 Trait which tests whether a type is a unit_value_t representing the given unit type. More...
 
struct  units::traits::is_unit_value_t_category< Category, T >
 Trait which tests whether type T is a unit_value_t with a unit type in the given category. More...
 
struct  units::unit_value_add< U1, U2 >
 adds two unit_value_t types at compile-time More...
 
struct  units::unit_value_subtract< U1, U2 >
 subtracts two unit_value_t types at compile-time More...
 
struct  units::unit_value_multiply< U1, U2 >
 multiplies two unit_value_t types at compile-time More...
 
struct  units::unit_value_divide< U1, U2 >
 divides two unit_value_t types at compile-time More...
 
struct  units::unit_value_power< U1, power >
 raises unit_value_to a power at compile-time More...
 
struct  units::unit_value_sqrt< U1, Eps >
 calculates square root of unit_value_t at compile-time More...
 

Namespaces

namespace  units
 Unit Conversion Library namespace.
 
namespace  units::detail
 
namespace  units::traits
 namespace representing type traits which can access the properties of types provided by the units library.
 
namespace  units::category
 namespace representing the implemented base and derived unit types.
 
namespace  units::dimensionless
 namespace for unit types and containers for units that have no dimension (scalar units)
 
namespace  units::math
 namespace for unit-enabled versions of the <cmath> library
 
namespace  units::literals
 

Macros

#define UNIT_HAS_LITERAL_SUPPORT
 
#define UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT
 
#define UNIT_LIB_DEFAULT_TYPE   double
 
#define UNIT_ADD_UNIT_TAGS(namespaceName, nameSingular, namePlural, abbreviation, ...)
 Helper macro for generating the boiler-plate code generating the tags of a new unit. More...
 
#define UNIT_ADD_UNIT_DEFINITION(namespaceName, nameSingular)
 Macro for generating the boiler-plate code for the unit_t type definition. More...
 
#define UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION(namespaceName, nameSingular, underlyingType)
 Macro for generating the boiler-plate code for a unit_t type definition with a non-default underlying type. More...
 
#define UNIT_ADD_NAME(namespaceName, nameSingular, abbrev)
 Macro for generating constexpr names/abbreviations for units. More...
 
#define UNIT_ADD_LITERALS(namespaceName, nameSingular, abbreviation)
 Macro for generating user-defined literals for units. More...
 
#define UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation, ...)
 Macro for generating the boiler-plate code needed for a new unit. More...
 
#define UNIT_ADD_WITH_CUSTOM_TYPE(namespaceName, nameSingular, namePlural, abbreviation, underlyingType, ...)
 Macro for generating the boiler-plate code needed for a new unit with a non-default underlying type. More...
 
#define UNIT_ADD_DECIBEL(namespaceName, nameSingular, abbreviation)
 Macro to create decibel container and literals for an existing unit type. More...
 
#define UNIT_ADD_CATEGORY_TRAIT_DETAIL(unitCategory)
 
#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)
 
#define UNIT_ADD_CATEGORY_TRAIT(unitCategory)
 Macro to create the is_category_unit type trait. More...
 
#define UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, ...)
 Macro for generating the boiler-plate code needed for a new unit, including its metric prefixes from femto to peta. More...
 
#define UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, ...)
 Macro for generating the boiler-plate code needed for a new unit, including its metric prefixes from femto to peta, and binary prefixes from kibi to exbi. More...
 

Typedefs

typedef base_unit units::category::scalar_unit
 Represents a quantity with no dimension. More...
 
typedef base_unit units::category::dimensionless_unit
 Represents a quantity with no dimension. More...
 
typedef base_unit< detail::meter_ratio< 1 > > units::category::length_unit
 Represents an SI base unit of length. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 1 > > units::category::mass_unit
 Represents an SI base unit of mass. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::time_unit
 Represents an SI base unit of time. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::angle_unit
 Represents an SI base unit of angle. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::current_unit
 Represents an SI base unit of current. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::temperature_unit
 Represents an SI base unit of temperature. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::substance_unit
 Represents an SI base unit of amount of substance. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::luminous_intensity_unit
 Represents an SI base unit of luminous intensity. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 2 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 > > units::category::solid_angle_unit
 Represents an SI derived unit of solid angle. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 > > units::category::frequency_unit
 Represents an SI derived unit of frequency. More...
 
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 0 >, std::ratio<-1 > > units::category::velocity_unit
 Represents an SI derived unit of velocity. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 >, std::ratio< 1 > > units::category::angular_velocity_unit
 Represents an SI derived unit of angular velocity. More...
 
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 0 >, std::ratio<-2 > > units::category::acceleration_unit
 Represents an SI derived unit of acceleration. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-2 >, std::ratio< 1 > > units::category::angular_acceleration_unit
 Represents an SI derived unit of angular acceleration. More...
 
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 1 >, std::ratio<-2 > > units::category::force_unit
 Represents an SI derived unit of force. More...
 
typedef base_unit< detail::meter_ratio<-1 >, std::ratio< 1 >, std::ratio<-2 > > units::category::pressure_unit
 Represents an SI derived unit of pressure. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 1 >, std::ratio< 0 >, std::ratio< 1 > > units::category::charge_unit
 Represents an SI derived unit of charge. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 > > units::category::energy_unit
 Represents an SI derived unit of energy. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-3 > > units::category::power_unit
 Represents an SI derived unit of power. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-3 >, std::ratio< 0 >, std::ratio<-1 > > units::category::voltage_unit
 Represents an SI derived unit of voltage. More...
 
typedef base_unit< detail::meter_ratio<-2 >, std::ratio<-1 >, std::ratio< 4 >, std::ratio< 0 >, std::ratio< 2 > > units::category::capacitance_unit
 Represents an SI derived unit of capacitance. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-3 >, std::ratio< 0 >, std::ratio<-2 > > units::category::impedance_unit
 Represents an SI derived unit of impedance. More...
 
typedef base_unit< detail::meter_ratio<-2 >, std::ratio<-1 >, std::ratio< 3 >, std::ratio< 0 >, std::ratio< 2 > > units::category::conductance_unit
 Represents an SI derived unit of conductance. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 >, std::ratio< 0 >, std::ratio<-1 > > units::category::magnetic_flux_unit
 Represents an SI derived unit of magnetic flux. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 1 >, std::ratio<-2 >, std::ratio< 0 >, std::ratio<-1 > > units::category::magnetic_field_strength_unit
 Represents an SI derived unit of magnetic field strength. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 >, std::ratio< 0 >, std::ratio<-2 > > units::category::inductance_unit
 Represents an SI derived unit of inductance. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 2 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::luminous_flux_unit
 Represents an SI derived unit of luminous flux. More...
 
typedef base_unit< detail::meter_ratio<-2 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 2 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::illuminance_unit
 Represents an SI derived unit of illuminance. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 > > units::category::radioactivity_unit
 Represents an SI derived unit of radioactivity. More...
 
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 > > units::category::torque_unit
 Represents an SI derived unit of torque. More...
 
typedef base_unit< detail::meter_ratio< 2 > > units::category::area_unit
 Represents an SI derived unit of area. More...
 
typedef base_unit< detail::meter_ratio< 3 > > units::category::volume_unit
 Represents an SI derived unit of volume. More...
 
typedef base_unit< detail::meter_ratio<-3 >, std::ratio< 1 > > units::category::density_unit
 Represents an SI derived unit of density. More...
 
typedef base_unit units::category::concentration_unit
 Represents a unit of concentration. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::data_unit
 Represents a unit of data size. More...
 
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > units::category::data_transfer_rate_unit
 Represents a unit of data transfer rate. More...
 
template<class U >
using units::traits::base_unit_of = typename units::detail::base_unit_of_impl< U >::type
 Trait which returns the base_unit type that a unit is originally derived from. More...
 
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<typename 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. 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 , class... Us>
using units::compound_unit = typename units::detail::compound_impl< U, Us... >::type
 Represents a unit type made up from other units. More...
 
typedef unit< std::ratio< 1 >, units::category::scalar_unitunits::dimensionless::scalar
 
typedef unit< std::ratio< 1 >, units::category::dimensionless_unitunits::dimensionless::dimensionless
 
typedef unit_t< scalar > units::dimensionless::scalar_t
 
typedef scalar_t units::dimensionless::dimensionless_t
 
typedef unit_t< scalar, UNIT_LIB_DEFAULT_TYPE, decibel_scale > units::dimensionless::dB_t
 
typedef dB_t units::dimensionless::dBi_t
 
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...
 

Functions

template<typename T >
std::string units::detail::to_string (const T &t)
 
template<typename T >
constexpr const char * units::name (const T &)
 
template<typename T >
constexpr const char * units::abbreviation (const T &)
 
template<class UnitFrom , class UnitTo , typename T = UNIT_LIB_DEFAULT_TYPE>
static constexpr T units::convert (const T &value) noexcept
 converts a value from one type to another. More...
 
template<class UnitType , typename T , class = std::enable_if_t<std::is_arithmetic<T>::value>>
constexpr UnitType units::make_unit (const T value) noexcept
 Constructs a unit container from an arithmetic type. More...
 
template<class Units , typename T , template< typename > class NonLinearScale, typename RhsType >
unit_t< Units, T, NonLinearScale > & units::operator+= (unit_t< Units, T, NonLinearScale > &lhs, const RhsType &rhs) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale, typename RhsType >
unit_t< Units, T, NonLinearScale > & units::operator-= (unit_t< Units, T, NonLinearScale > &lhs, const RhsType &rhs) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale, typename RhsType >
unit_t< Units, T, NonLinearScale > & units::operator*= (unit_t< Units, T, NonLinearScale > &lhs, const RhsType &rhs) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale, typename RhsType >
unit_t< Units, T, NonLinearScale > & units::operator/= (unit_t< Units, T, NonLinearScale > &lhs, const RhsType &rhs) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
constexpr unit_t< Units, T, NonLinearScale > units::operator+ (const unit_t< Units, T, NonLinearScale > &u) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
unit_t< Units, T, NonLinearScale > & units::operator++ (unit_t< Units, T, NonLinearScale > &u) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
unit_t< Units, T, NonLinearScale > units::operator++ (unit_t< Units, T, NonLinearScale > &u, int) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
constexpr unit_t< Units, T, NonLinearScale > units::operator- (const unit_t< Units, T, NonLinearScale > &u) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
unit_t< Units, T, NonLinearScale > & units::operator-- (unit_t< Units, T, NonLinearScale > &u) noexcept
 
template<class Units , typename T , template< typename > class NonLinearScale>
unit_t< Units, T, NonLinearScale > units::operator-- (unit_t< Units, T, NonLinearScale > &u, int) noexcept
 
template<typename T , typename Units , class = std::enable_if_t<std::is_arithmetic<T>::value && traits::is_unit_t<Units>::value>>
constexpr T units::unit_cast (const Units &value) noexcept
 Casts a unit container to an arithmetic type. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t<!traits::is_same_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr int units::operator+ (const UnitTypeLhs &, const UnitTypeRhs &) noexcept
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator+ (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Addition operator for unit_t types with a linear_scale. More...
 
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
constexpr dimensionless::scalar_t units::operator+ (const dimensionless::scalar_t &lhs, T rhs) noexcept
 Addition operator for scalar unit_t types with a linear_scale. Scalar types can be implicitly converted to built-in types. More...
 
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
constexpr dimensionless::scalar_t units::operator+ (T lhs, const dimensionless::scalar_t &rhs) noexcept
 Addition operator for scalar unit_t types with a linear_scale. Scalar types can be implicitly converted to built-in types. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator- (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Subtraction operator for unit_t types with a linear_scale. More...
 
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
constexpr dimensionless::scalar_t units::operator- (const dimensionless::scalar_t &lhs, T rhs) noexcept
 Subtraction operator for scalar unit_t types with a linear_scale. Scalar types can be implicitly converted to built-in types. More...
 
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
constexpr dimensionless::scalar_t units::operator- (T lhs, const dimensionless::scalar_t &rhs) noexcept
 Subtraction operator for scalar unit_t types with a linear_scale. Scalar types can be implicitly converted to built-in types. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::is_convertible_unit_t< UnitTypeLhs, UnitTypeRhs >::value &&traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator* (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< compound_unit< squared< typename units::traits::unit_t_traits< UnitTypeLhs >::unit_type > > >
 Multiplication type for convertible unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , typename UnitTypeRhs , std::enable_if_t< traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value &&!traits::is_dimensionless_unit< UnitTypeLhs >::value &&traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator* (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Multiplication by a dimensionless unit for unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , typename UnitTypeRhs , std::enable_if_t< traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value &&traits::is_dimensionless_unit< UnitTypeLhs >::value &&!traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeRhs units::operator* (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Multiplication by a dimensionless unit for unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , typename T , std::enable_if_t< std::is_arithmetic< T >::value &&traits::has_linear_scale< UnitTypeLhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator* (const UnitTypeLhs &lhs, T rhs) noexcept
 Multiplication by a scalar for unit_t types with a linear scale. More...
 
template<class UnitTypeRhs , typename T , std::enable_if_t< std::is_arithmetic< T >::value &&traits::has_linear_scale< UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeRhs units::operator* (T lhs, const UnitTypeRhs &rhs) noexcept
 Multiplication by a scalar for unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::is_convertible_unit_t< UnitTypeLhs, UnitTypeRhs >::value &&traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr dimensionless::scalar_t units::operator/ (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Division for convertible unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t<!traits::is_convertible_unit_t< UnitTypeLhs, UnitTypeRhs >::value &&traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value &&!traits::is_dimensionless_unit< UnitTypeLhs >::value &&!traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator/ (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< compound_unit< typename units::traits::unit_t_traits< UnitTypeLhs >::unit_type, inverse< typename units::traits::unit_t_traits< UnitTypeRhs >::unit_type > > >
 Division for non-convertible unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value &&!traits::is_dimensionless_unit< UnitTypeLhs >::value &&traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator/ (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept
 Division by a dimensionless unit for unit_t types with a linear scale. More...
 
template<class UnitTypeLhs , typename T , std::enable_if_t< std::is_arithmetic< T >::value &&traits::has_linear_scale< UnitTypeLhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator/ (const UnitTypeLhs &lhs, T rhs) noexcept
 Division by a scalar for unit_t types with a linear scale. More...
 
template<class UnitTypeRhs , typename T , std::enable_if_t< std::is_arithmetic< T >::value &&traits::has_linear_scale< UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator/ (T lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< inverse< typename units::traits::unit_t_traits< UnitTypeRhs >::unit_type > >
 Division of a scalar by a unit_t type with a linear scale. More...
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator== (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator== (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator!= (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator!= (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator>= (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator>= (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator> (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator> (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator<= (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator<= (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator< (const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
 
template<typename Units , class = std::enable_if_t<units::traits::is_dimensionless_unit<Units>::value>>
constexpr bool units::operator< (const Units &lhs, const UNIT_LIB_DEFAULT_TYPE rhs) noexcept
 
template<int power, class UnitType , class = typename std::enable_if<traits::has_linear_scale<UnitType>::value, int>>
auto units::math::pow (const UnitType &value) noexcept -> unit_t< typename units::detail::power_of_unit< power, typename units::traits::unit_t_traits< UnitType >::unit_type >::type, typename units::traits::unit_t_traits< UnitType >::underlying_type, linear_scale >
 computes the value of value raised to the power More...
 
template<int power, class UnitType , class = typename std::enable_if<traits::has_linear_scale<UnitType>::value, int>>
constexpr auto units::math::cpow (const UnitType &value) noexcept -> unit_t< typename units::detail::power_of_unit< power, typename units::traits::unit_t_traits< UnitType >::unit_type >::type, typename units::traits::unit_t_traits< UnitType >::underlying_type, linear_scale >
 computes the value of value raised to the power as a constexpr More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator+ (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< compound_unit< squared< typename units::traits::unit_t_traits< UnitTypeLhs >::unit_type > >, typename units::traits::unit_t_traits< UnitTypeLhs >::underlying_type, decibel_scale >
 Addition for convertible unit_t types with a decibel_scale. More...
 
template<class UnitTypeLhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeLhs >::value &&!traits::is_dimensionless_unit< UnitTypeLhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator+ (const UnitTypeLhs &lhs, const dimensionless::dB_t &rhs) noexcept
 Addition between unit_t types with a decibel_scale and dimensionless dB units. More...
 
template<class UnitTypeRhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeRhs >::value &&!traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr UnitTypeRhs units::operator+ (const dimensionless::dB_t &lhs, const UnitTypeRhs &rhs) noexcept
 Addition between unit_t types with a decibel_scale and dimensionless dB units. More...
 
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator- (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< compound_unit< typename units::traits::unit_t_traits< UnitTypeLhs >::unit_type, inverse< typename units::traits::unit_t_traits< UnitTypeRhs >::unit_type > >, typename units::traits::unit_t_traits< UnitTypeLhs >::underlying_type, decibel_scale >
 Subtraction for convertible unit_t types with a decibel_scale. More...
 
template<class UnitTypeLhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeLhs >::value &&!traits::is_dimensionless_unit< UnitTypeLhs >::value, int > = 0>
constexpr UnitTypeLhs units::operator- (const UnitTypeLhs &lhs, const dimensionless::dB_t &rhs) noexcept
 Subtraction between unit_t types with a decibel_scale and dimensionless dB units. More...
 
template<class UnitTypeRhs , std::enable_if_t< traits::has_decibel_scale< UnitTypeRhs >::value &&!traits::is_dimensionless_unit< UnitTypeRhs >::value, int > = 0>
constexpr auto units::operator- (const dimensionless::dB_t &lhs, const UnitTypeRhs &rhs) noexcept -> unit_t< inverse< typename units::traits::unit_t_traits< UnitTypeRhs >::unit_type >, typename units::traits::unit_t_traits< UnitTypeRhs >::underlying_type, decibel_scale >
 Subtraction between unit_t types with a decibel_scale and dimensionless dB units. More...
 
template<class UnitTypeLhs , class UnitTypeRhs >
UnitTypeLhs() units::math::min (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
 
template<class UnitTypeLhs , class UnitTypeRhs >
UnitTypeLhs() units::math::max (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
 

Variables

template<class T >
constexpr bool units::traits::is_ratio_v = is_ratio<T>::value
 
template<class T >
constexpr bool units::traits::is_unit_v = is_unit<T>::value
 
template<class U1 , class U2 >
constexpr bool units::traits::is_convertible_unit_v = is_convertible_unit<U1, U2>::value
 
template<class T >
constexpr bool units::traits::is_unit_t_v = is_unit_t<T>::value
 
template<typename... T>
constexpr bool units::traits::has_linear_scale_v = has_linear_scale<T...>::value
 
template<typename... T>
constexpr bool units::traits::has_decibel_scale_v = has_decibel_scale<T...>::value
 
template<typename T1 , typename T2 >
constexpr bool units::traits::is_same_scale_v = is_same_scale<T1, T2>::value
 
template<typename T , typename Units = typename traits::unit_value_t_traits<T>::unit_type>
constexpr bool units::traits::is_unit_value_t_v = is_unit_value_t<T, Units>::value
 
template<typename Category , typename T >
constexpr bool units::traits::is_unit_value_t_category_v = is_unit_value_t_category<Category, T>::value
 

Macro Definition Documentation

◆ UNIT_ADD

#define UNIT_ADD (   namespaceName,
  nameSingular,
  namePlural,
  abbreviation,
  ... 
)
Value:
UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, __VA_ARGS__)\
UNIT_ADD_UNIT_DEFINITION(namespaceName,nameSingular)\
UNIT_ADD_NAME(namespaceName,nameSingular, abbreviation)\
UNIT_ADD_IO(namespaceName,nameSingular, abbreviation)\
UNIT_ADD_LITERALS(namespaceName,nameSingular, abbreviation)
#define UNIT_ADD_UNIT_TAGS(namespaceName, nameSingular, namePlural, abbreviation,...)
Helper macro for generating the boiler-plate code generating the tags of a new unit.
Definition: base.h:135
constexpr const char * abbreviation(const T &)

Macro for generating the boiler-plate code needed for a new unit.

The macro generates singular, plural, and abbreviated forms of the unit definition (e.g. meter, meters, and m), as well as the appropriately named unit container (e.g. meter_t). A literal suffix is created using the abbreviation (e.g. 10.0_m). It also defines a class-specific cout function which prints both the value and abbreviation of the unit when invoked.

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'meter'
namePlural- plural version of the unit name, e.g. 'meters'
abbreviation- abbreviated unit name, e.g. 'm'
definition- the variadic parameter is used for the definition of the unit (e.g. unit<std::ratio<1>, units::category::length_unit>)
Note
a variadic template is used for the definition to allow templates with commas to be easily expanded. All the variadic 'arguments' should together comprise the unit definition.

◆ UNIT_ADD_CATEGORY_TRAIT

#define UNIT_ADD_CATEGORY_TRAIT (   unitCategory)
Value:
/** @ingroup TypeTraits*/\
/** @brief Trait which tests whether a type represents a unit of unitCategory*/\
/** @details Inherits from `std::true_type` or `std::false_type`. Use `is_ ## unitCategory ## _unit<T>::value` to test the unit represents a unitCategory quantity.*/\
/** @tparam T one or more types to test*/\
UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)
#define UNIT_ADD_CATEGORY_TRAIT_DETAIL(unitCategory)
Definition: base.h:346

Macro to create the is_category_unit type trait.

This trait allows users to test whether a given type matches an intended category. This macro comprises all the boiler-plate code necessary to do so.

Parameters
unitCategoryThe name of the category of unit, e.g. length or mass.

◆ UNIT_ADD_CATEGORY_TRAIT_DETAIL

#define UNIT_ADD_CATEGORY_TRAIT_DETAIL (   unitCategory)
Value:
namespace traits\
{\
/** @cond */\
namespace detail\
{\
template<typename T> struct is_ ## unitCategory ## _unit_impl : std::false_type {};\
template<typename C, typename U, typename P, typename T>\
struct is_ ## unitCategory ## _unit_impl<units::unit<C, U, P, T>> : std::is_same<units::traits::base_unit_of<typename units::traits::unit_traits<units::unit<C, U, P, T>>::base_unit_type>, units::category::unitCategory ## _unit>::type {};\
template<typename U, typename S, template<typename> class N>\
struct is_ ## unitCategory ## _unit_impl<units::unit_t<U, S, N>> : std::is_same<units::traits::base_unit_of<typename units::traits::unit_t_traits<units::unit_t<U, S, N>>::unit_type>, units::category::unitCategory ## _unit>::type {};\
}\
/** @endcond */\
}
type
Definition: core.h:575
Definition: format-inl.h:32
Unit Conversion Library namespace.
Definition: magnetic_flux.h:31

◆ UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION

#define UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION (   namespaceName,
  nameSingular,
  underlyingType 
)
Value:
namespace namespaceName\
{\
/** @name Unit Containers */ /** @{ */ typedef unit_t<nameSingular,underlyingType> nameSingular ## _t; /** @} */\
}

Macro for generating the boiler-plate code for a unit_t type definition with a non-default underlying type.

The macro generates the definition of the unit container types, e.g. meter_t

Parameters
namespaceNamenamespace in which the new units will be encapsulated.
nameSingularsingular version of the unit name, e.g. 'meter'
underlyingTypethe underlying type

◆ UNIT_ADD_DECIBEL

#define UNIT_ADD_DECIBEL (   namespaceName,
  nameSingular,
  abbreviation 
)
Value:
namespace namespaceName\
{\
/** @name Unit Containers */ /** @{ */ typedef unit_t<nameSingular, UNIT_LIB_DEFAULT_TYPE, units::decibel_scale> abbreviation ## _t; /** @} */\
}\
UNIT_ADD_IO(namespaceName, abbreviation, abbreviation)\
UNIT_ADD_LITERALS(namespaceName, abbreviation, abbreviation)

Macro to create decibel container and literals for an existing unit type.

This macro generates the decibel unit container, cout overload, and literal definitions.

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the base unit name, e.g. 'watt'
abbreviation- abbreviated decibel unit name, e.g. 'dBW'

◆ UNIT_ADD_IS_UNIT_CATEGORY_TRAIT

#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT (   unitCategory)
Value:
namespace traits\
{\
template<typename... T> struct is_ ## unitCategory ## _unit : std::integral_constant<bool, units::all_true<units::traits::detail::is_ ## unitCategory ## _unit_impl<std::decay_t<T>>::value...>::value> {};\
template<typename... T> inline constexpr bool is_ ## unitCategory ## _unit_v = is_ ## unitCategory ## _unit<T...>::value;\
}
Definition: core.h:1240

◆ UNIT_ADD_LITERALS

#define UNIT_ADD_LITERALS (   namespaceName,
  nameSingular,
  abbreviation 
)
Value:
namespace literals\
{\
inline constexpr namespaceName::nameSingular ## _t operator""_ ## abbreviation(long double d)\
{\
return namespaceName::nameSingular ## _t(static_cast<namespaceName::nameSingular ## _t::underlying_type>(d));\
}\
inline constexpr namespaceName::nameSingular ## _t operator""_ ## abbreviation (unsigned long long d)\
{\
return namespaceName::nameSingular ## _t(static_cast<namespaceName::nameSingular ## _t::underlying_type>(d));\
}\
}
Definition: xchar.h:50

Macro for generating user-defined literals for units.

The macro generates user-defined literals for units. A literal suffix is created using the abbreviation (e.g. 10.0_m).

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'meter'
abbreviation- abbreviated unit name, e.g. 'm'
Note
When UNIT_HAS_LITERAL_SUPPORT is not defined, the macro does not generate any code

◆ UNIT_ADD_NAME

#define UNIT_ADD_NAME (   namespaceName,
  nameSingular,
  abbrev 
)
Value:
template<> inline constexpr const char* name(const namespaceName::nameSingular ## _t&)\
{\
return #nameSingular;\
}\
template<> inline constexpr const char* abbreviation(const namespaceName::nameSingular ## _t&)\
{\
return #abbrev;\
}

Macro for generating constexpr names/abbreviations for units.

The macro generates names for units. E.g. name() of 1_m would be "meter", and abbreviation would be "m".

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'meter'
abbreviation- abbreviated unit name, e.g. 'm'

◆ UNIT_ADD_UNIT_DEFINITION

#define UNIT_ADD_UNIT_DEFINITION (   namespaceName,
  nameSingular 
)
Value:
namespace namespaceName\
{\
/** @name Unit Containers */ /** @{ */ typedef unit_t<nameSingular> nameSingular ## _t; /** @} */\
}

Macro for generating the boiler-plate code for the unit_t type definition.

The macro generates the definition of the unit container types, e.g. meter_t

Parameters
namespaceNamenamespace in which the new units will be encapsulated.
nameSingularsingular version of the unit name, e.g. 'meter'

◆ UNIT_ADD_UNIT_TAGS

#define UNIT_ADD_UNIT_TAGS (   namespaceName,
  nameSingular,
  namePlural,
  abbreviation,
  ... 
)
Value:
namespace namespaceName\
{\
/** @name Units (full names plural) */ /** @{ */ typedef __VA_ARGS__ namePlural; /** @} */\
/** @name Units (full names singular) */ /** @{ */ typedef namePlural nameSingular; /** @} */\
/** @name Units (abbreviated) */ /** @{ */ typedef namePlural abbreviation; /** @} */\
}

Helper macro for generating the boiler-plate code generating the tags of a new unit.

The macro generates singular, plural, and abbreviated forms of the unit definition (e.g. meter, meters, and m), as aliases for the unit tag.

Parameters
namespaceNamenamespace in which the new units will be encapsulated.
nameSingularsingular version of the unit name, e.g. 'meter'
namePlural- plural version of the unit name, e.g. 'meters'
abbreviation- abbreviated unit name, e.g. 'm'
definition- the variadic parameter is used for the definition of the unit (e.g. unit<std::ratio<1>, units::category::length_unit>)
Note
a variadic template is used for the definition to allow templates with commas to be easily expanded. All the variadic 'arguments' should together comprise the unit definition.

◆ UNIT_ADD_WITH_CUSTOM_TYPE

#define UNIT_ADD_WITH_CUSTOM_TYPE (   namespaceName,
  nameSingular,
  namePlural,
  abbreviation,
  underlyingType,
  ... 
)
Value:
UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, __VA_ARGS__)\
UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION(namespaceName,nameSingular,underlyingType)\
UNIT_ADD_IO(namespaceName,nameSingular, abbreviation)\
UNIT_ADD_LITERALS(namespaceName,nameSingular, abbreviation)

Macro for generating the boiler-plate code needed for a new unit with a non-default underlying type.

The macro generates singular, plural, and abbreviated forms of the unit definition (e.g. meter, meters, and m), as well as the appropriately named unit container (e.g. meter_t). A literal suffix is created using the abbreviation (e.g. 10.0_m). It also defines a class-specific cout function which prints both the value and abbreviation of the unit when invoked.

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'meter'
namePlural- plural version of the unit name, e.g. 'meters'
abbreviation- abbreviated unit name, e.g. 'm'
underlyingType- the underlying type, e.g. 'int' or 'float'
definition- the variadic parameter is used for the definition of the unit (e.g. unit<std::ratio<1>, units::category::length_unit>)
Note
a variadic template is used for the definition to allow templates with commas to be easily expanded. All the variadic 'arguments' should together comprise the unit definition.

◆ UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES

#define UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES (   namespaceName,
  nameSingular,
  namePlural,
  abbreviation,
  ... 
)
Value:
UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, __VA_ARGS__)\
UNIT_ADD(namespaceName, kibi ## nameSingular, kibi ## namePlural, Ki ## abbreviation, kibi<namePlural>)\
UNIT_ADD(namespaceName, mebi ## nameSingular, mebi ## namePlural, Mi ## abbreviation, mebi<namePlural>)\
UNIT_ADD(namespaceName, gibi ## nameSingular, gibi ## namePlural, Gi ## abbreviation, gibi<namePlural>)\
UNIT_ADD(namespaceName, tebi ## nameSingular, tebi ## namePlural, Ti ## abbreviation, tebi<namePlural>)\
UNIT_ADD(namespaceName, pebi ## nameSingular, pebi ## namePlural, Pi ## abbreviation, pebi<namePlural>)\
UNIT_ADD(namespaceName, exbi ## nameSingular, exbi ## namePlural, Ei ## abbreviation, exbi<namePlural>)
#define UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation,...)
Macro for generating the boiler-plate code needed for a new unit, including its metric prefixes from ...
Definition: base.h:407
typename units::detail::prefix< std::ratio< 1099511627776 >, U >::type tebi
Represents the type of class U with the binary 'tebi' prefix appended.
Definition: base.h:1515
typename units::detail::prefix< std::ratio< 1048576 >, U >::type mebi
Represents the type of class U with the binary 'mibi' prefix appended.
Definition: base.h:1513
typename units::detail::prefix< std::ratio< 1152921504606846976 >, U >::type exbi
Represents the type of class U with the binary 'exbi' prefix appended.
Definition: base.h:1517
typename units::detail::prefix< std::ratio< 1073741824 >, U >::type gibi
Represents the type of class U with the binary 'gibi' prefix appended.
Definition: base.h:1514
typename units::detail::prefix< std::ratio< 1125899906842624 >, U >::type pebi
Represents the type of class U with the binary 'pebi' prefix appended.
Definition: base.h:1516
typename units::detail::prefix< std::ratio< 1024 >, U >::type kibi
Represents the type of class U with the binary 'kibi' prefix appended.
Definition: base.h:1512

Macro for generating the boiler-plate code needed for a new unit, including its metric prefixes from femto to peta, and binary prefixes from kibi to exbi.

See UNIT_ADD. In addition to generating the unit definition and containers '(e.g. bytes and 'byte_t', it also creates corresponding units with metric suffixes such as millimeters, and millimeter_t), as well as the literal suffixes (e.g. 10.0_B).

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'byte'
namePlural- plural version of the unit name, e.g. 'bytes'
abbreviation- abbreviated unit name, e.g. 'B'
definition- the variadic parameter is used for the definition of the unit (e.g. unit<std::ratio<1>, units::category::data_unit>)
Note
a variadic template is used for the definition to allow templates with commas to be easily expanded. All the variadic 'arguments' should together comprise the unit definition.

◆ UNIT_ADD_WITH_METRIC_PREFIXES

#define UNIT_ADD_WITH_METRIC_PREFIXES (   namespaceName,
  nameSingular,
  namePlural,
  abbreviation,
  ... 
)
Value:
UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation, __VA_ARGS__)\
UNIT_ADD(namespaceName, femto ## nameSingular, femto ## namePlural, f ## abbreviation, femto<namePlural>)\
UNIT_ADD(namespaceName, pico ## nameSingular, pico ## namePlural, p ## abbreviation, pico<namePlural>)\
UNIT_ADD(namespaceName, nano ## nameSingular, nano ## namePlural, n ## abbreviation, nano<namePlural>)\
UNIT_ADD(namespaceName, micro ## nameSingular, micro ## namePlural, u ## abbreviation, micro<namePlural>)\
UNIT_ADD(namespaceName, milli ## nameSingular, milli ## namePlural, m ## abbreviation, milli<namePlural>)\
UNIT_ADD(namespaceName, centi ## nameSingular, centi ## namePlural, c ## abbreviation, centi<namePlural>)\
UNIT_ADD(namespaceName, deci ## nameSingular, deci ## namePlural, d ## abbreviation, deci<namePlural>)\
UNIT_ADD(namespaceName, deca ## nameSingular, deca ## namePlural, da ## abbreviation, deca<namePlural>)\
UNIT_ADD(namespaceName, hecto ## nameSingular, hecto ## namePlural, h ## abbreviation, hecto<namePlural>)\
UNIT_ADD(namespaceName, kilo ## nameSingular, kilo ## namePlural, k ## abbreviation, kilo<namePlural>)\
UNIT_ADD(namespaceName, mega ## nameSingular, mega ## namePlural, M ## abbreviation, mega<namePlural>)\
UNIT_ADD(namespaceName, giga ## nameSingular, giga ## namePlural, G ## abbreviation, giga<namePlural>)\
UNIT_ADD(namespaceName, tera ## nameSingular, tera ## namePlural, T ## abbreviation, tera<namePlural>)\
UNIT_ADD(namespaceName, peta ## nameSingular, peta ## namePlural, P ## abbreviation, peta<namePlural>)\
#define UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation,...)
Macro for generating the boiler-plate code needed for a new unit.
Definition: base.h:287
typename units::detail::prefix< std::peta, U >::type peta
Represents the type of class U with the metric 'peta' prefix appended.
Definition: base.h:1502
typename units::detail::prefix< std::milli, U >::type milli
Represents the type of class U with the metric 'milli' prefix appended.
Definition: base.h:1493
typename units::detail::prefix< std::micro, U >::type micro
Represents the type of class U with the metric 'micro' prefix appended.
Definition: base.h:1492
typename units::detail::prefix< std::giga, U >::type giga
Represents the type of class U with the metric 'giga' prefix appended.
Definition: base.h:1500
typename units::detail::prefix< std::deca, U >::type deca
Represents the type of class U with the metric 'deca' prefix appended.
Definition: base.h:1496
typename units::detail::prefix< std::deci, U >::type deci
Represents the type of class U with the metric 'deci' prefix appended.
Definition: base.h:1495
typename units::detail::prefix< std::femto, U >::type femto
Represents the type of class U with the metric 'femto' prefix appended.
Definition: base.h:1489
typename units::detail::prefix< std::pico, U >::type pico
Represents the type of class U with the metric 'pico' prefix appended.
Definition: base.h:1490
typename units::detail::prefix< std::tera, U >::type tera
Represents the type of class U with the metric 'tera' prefix appended.
Definition: base.h:1501
typename units::detail::prefix< std::hecto, U >::type hecto
Represents the type of class U with the metric 'hecto' prefix appended.
Definition: base.h:1497
typename units::detail::prefix< std::centi, U >::type centi
Represents the type of class U with the metric 'centi' prefix appended.
Definition: base.h:1494
typename units::detail::prefix< std::nano, U >::type nano
Represents the type of class U with the metric 'nano' prefix appended.
Definition: base.h:1491
typename units::detail::prefix< std::mega, U >::type mega
Represents the type of class U with the metric 'mega' prefix appended.
Definition: base.h:1499
typename units::detail::prefix< std::kilo, U >::type kilo
Represents the type of class U with the metric 'kilo' prefix appended.
Definition: base.h:1498
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
G
Definition: magnetic_field_strength.h:52

Macro for generating the boiler-plate code needed for a new unit, including its metric prefixes from femto to peta.

See UNIT_ADD. In addition to generating the unit definition and containers '(e.g. meters and 'meter_t', it also creates corresponding units with metric suffixes such as millimeters, and millimeter_t), as well as the literal suffixes (e.g. 10.0_mm).

Parameters
namespaceNamenamespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace.
nameSingularsingular version of the unit name, e.g. 'meter'
namePlural- plural version of the unit name, e.g. 'meters'
abbreviation- abbreviated unit name, e.g. 'm'
definition- the variadic parameter is used for the definition of the unit (e.g. unit<std::ratio<1>, units::category::length_unit>)
Note
a variadic template is used for the definition to allow templates with commas to be easily expanded. All the variadic 'arguments' should together comprise the unit definition.

◆ UNIT_HAS_LITERAL_SUPPORT

#define UNIT_HAS_LITERAL_SUPPORT

◆ UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT

#define UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT

◆ UNIT_LIB_DEFAULT_TYPE

#define UNIT_LIB_DEFAULT_TYPE   double