#include <chrono>
#include <ratio>
#include <type_traits>
#include <cstdint>
#include <cmath>
#include <limits>
#include <gcem.hpp>
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_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. | |
#define | UNIT_ADD_UNIT_DEFINITION(namespaceName, nameSingular) |
Macro for generating the boiler-plate code for the unit_t type definition. | |
#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. | |
#define | UNIT_ADD_IO(namespaceName, nameSingular, abbrev) |
Macro for generating the boiler-plate code needed for I/O for a new unit. | |
#define | UNIT_ADD_NAME(namespaceName, nameSingular, abbrev) |
Macro for generating constexpr names/abbreviations for units. | |
#define | UNIT_ADD_LITERALS(namespaceName, nameSingular, abbreviation) |
Macro for generating user-defined literals for units. | |
#define | UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation, ...) |
Macro for generating the boiler-plate code needed for a new unit. | |
#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. | |
#define | UNIT_ADD_DECIBEL(namespaceName, nameSingular, abbreviation) |
Macro to create decibel container and literals for an existing unit type. | |
#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. | |
#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. | |
#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. | |
Typedefs | |
typedef base_unit | units::category::scalar_unit |
Represents a quantity with no dimension. | |
typedef base_unit | units::category::dimensionless_unit |
Represents a quantity with no dimension. | |
typedef base_unit< detail::meter_ratio< 1 > > | units::category::length_unit |
Represents an SI base unit of length. | |
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 1 > > | units::category::mass_unit |
Represents an SI base unit of mass. | |
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio< 1 > > | units::category::time_unit |
Represents an SI base unit of time. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 > > | units::category::frequency_unit |
Represents an SI derived unit of frequency. | |
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 0 >, std::ratio<-1 > > | units::category::velocity_unit |
Represents an SI derived unit of velocity. | |
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. | |
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 0 >, std::ratio<-2 > > | units::category::acceleration_unit |
Represents an SI derived unit of acceleration. | |
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. | |
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-3 >, std::ratio< 1 > > | units::category::angular_jerk_unit |
Represents an SI derived unit of angular jerk. | |
typedef base_unit< detail::meter_ratio< 1 >, std::ratio< 1 >, std::ratio<-2 > > | units::category::force_unit |
Represents an SI derived unit of force. | |
typedef base_unit< detail::meter_ratio<-1 >, std::ratio< 1 >, std::ratio<-2 > > | units::category::pressure_unit |
Represents an SI derived unit of pressure. | |
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. | |
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 > > | units::category::energy_unit |
Represents an SI derived unit of energy. | |
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-3 > > | units::category::power_unit |
Represents an SI derived unit of power. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
typedef base_unit< detail::meter_ratio< 0 >, std::ratio< 0 >, std::ratio<-1 > > | units::category::radioactivity_unit |
Represents an SI derived unit of radioactivity. | |
typedef base_unit< detail::meter_ratio< 2 >, std::ratio< 1 >, std::ratio<-2 > > | units::category::torque_unit |
Represents an SI derived unit of torque. | |
typedef base_unit< detail::meter_ratio< 2 > > | units::category::area_unit |
Represents an SI derived unit of area. | |
typedef base_unit< detail::meter_ratio< 3 > > | units::category::volume_unit |
Represents an SI derived unit of volume. | |
typedef base_unit< detail::meter_ratio<-3 >, std::ratio< 1 > > | units::category::density_unit |
Represents an SI derived unit of density. | |
typedef base_unit | units::category::concentration_unit |
Represents a unit of concentration. | |
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. | |
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. | |
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. | |
template<class U > | |
using | units::inverse = typename units::detail::inverse_impl<U>::type |
represents the inverse unit type of class U . | |
template<class U > | |
using | units::squared = typename units::detail::squared_impl<U>::type |
represents the unit type of class U squared | |
template<class U > | |
using | units::cubed = typename units::detail::cubed_impl<U>::type |
represents the type of class U cubed. | |
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. | |
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 . | |
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. | |
typedef unit< std::ratio< 1 >, units::category::scalar_unit > | units::dimensionless::scalar |
typedef unit< std::ratio< 1 >, units::category::dimensionless_unit > | units::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 |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
template<class U > | |
using | units::kibi = typename units::detail::prefix<std::ratio<1024>, U>::type |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
template<class Units , typename T , template< typename > class NonLinearScale, typename RhsType > | |
constexpr 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 > | |
constexpr 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 > | |
constexpr 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 > | |
constexpr 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> | |
constexpr unit_t< Units, T, NonLinearScale > & | units::operator++ (unit_t< Units, T, NonLinearScale > &u) noexcept |
template<class Units , typename T , template< typename > class NonLinearScale> | |
constexpr 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> | |
constexpr unit_t< Units, T, NonLinearScale > & | units::operator-- (unit_t< Units, T, NonLinearScale > &u) noexcept |
template<class Units , typename T , template< typename > class NonLinearScale> | |
constexpr 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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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>> | |
constexpr 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 | |
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 | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
template<class UnitTypeLhs , class UnitTypeRhs > | |
constexpr UnitTypeLhs | units::math::min (const UnitTypeLhs &lhs, const UnitTypeRhs &rhs) |
template<class UnitTypeLhs , class UnitTypeRhs > | |
constexpr 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 |
#define UNIT_ADD | ( | namespaceName, | |
nameSingular, | |||
namePlural, | |||
abbreviation, | |||
... ) |
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.
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular 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> ) |
#define UNIT_ADD_CATEGORY_TRAIT | ( | unitCategory | ) |
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.
unitCategory | The name of the category of unit, e.g. length or mass. |
#define UNIT_ADD_CATEGORY_TRAIT_DETAIL | ( | unitCategory | ) |
#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.
The macro generates the definition of the unit container types, e.g. meter_t
namespaceName | namespace in which the new units will be encapsulated. |
nameSingular | singular version of the unit name, e.g. 'meter' |
underlyingType | the underlying type |
#define UNIT_ADD_DECIBEL | ( | namespaceName, | |
nameSingular, | |||
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.
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular version of the base unit name, e.g. 'watt' |
abbreviation | - abbreviated decibel unit name, e.g. 'dBW' |
#define UNIT_ADD_IO | ( | namespaceName, | |
nameSingular, | |||
abbrev ) |
Macro for generating the boiler-plate code needed for I/O for a new unit.
The macro generates the code to insert units into an ostream. It prints both the value and abbreviation of the unit when invoked.
namespaceName | namespace in which the new units will be encapsulated. |
nameSingular | singular version of the unit name, e.g. 'meter' |
abbrev | - abbreviated unit name, e.g. 'm' |
#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT | ( | unitCategory | ) |
#define UNIT_ADD_LITERALS | ( | namespaceName, | |
nameSingular, | |||
abbreviation ) |
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
).
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular version of the unit name, e.g. 'meter' |
abbreviation | - abbreviated unit name, e.g. 'm' |
#define UNIT_ADD_NAME | ( | namespaceName, | |
nameSingular, | |||
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".
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular version of the unit name, e.g. 'meter' |
abbreviation | - abbreviated unit name, e.g. 'm' |
#define UNIT_ADD_UNIT_DEFINITION | ( | namespaceName, | |
nameSingular ) |
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
namespaceName | namespace in which the new units will be encapsulated. |
nameSingular | singular version of the unit name, e.g. 'meter' |
#define UNIT_ADD_UNIT_TAGS | ( | namespaceName, | |
nameSingular, | |||
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.
namespaceName | namespace in which the new units will be encapsulated. |
nameSingular | singular 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> ) |
#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.
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.
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular 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> ) |
#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.
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
).
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular 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> ) |
#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.
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
).
namespaceName | namespace in which the new units will be encapsulated. All literal values are placed in the units::literals namespace. |
nameSingular | singular 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> ) |
#define UNIT_HAS_LITERAL_SUPPORT |
#define UNIT_LIB_DEFAULT_TYPE double |