Cpp Utilities 1.2.3
Public Types | Static Public Attributes | List of all members
Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity > Struct Template Reference

The Unit struct is used to describe physical units. More...

#include <DimensionalAnalysis.hpp>

Public Types

using type = Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >
 Type of the struct itself. More...
 

Static Public Attributes

static constexpr std::tuple< int, int, int, int, int, int, int > factors
 Power factors of 7 base units. More...
 
static constexpr int factorLength = length
 Power factor of length unit. More...
 
static constexpr int factorMass = mass
 Power factor of length mass unit. More...
 
static constexpr int factorTime = time
 Power factor of length time unit. More...
 
static constexpr int factorCurrent = current
 Power factor of length current unit. More...
 
static constexpr int factorTemperature = temperature
 Power factor of length temperature unit. More...
 
static constexpr int factorAmountOfSubstance = amountOfSubstance
 Power factor of amount_of_substance unit unit. More...
 
static constexpr int factorLuminousIntensity = luminousIntensity
 Power factor of luminous_intensity unit unit. More...
 

Related Functions

(Note that these are not member functions.)

Unit Conversion

Helper typedef for unit conversion

template<typename Unit1 , typename Unit2 >
using UnitMultiply = Unit< Unit1::factorLength+Unit2::factorLength, Unit1::factorMass+Unit2::factorMass, Unit1::factorTime+Unit2::factorTime, Unit1::factorCurrent+Unit2::factorCurrent, Unit1::factorTemperature+Unit2::factorTemperature, Unit1::factorAmountOfSubstance+Unit2::factorAmountOfSubstance, Unit1::factorLuminousIntensity+Unit2::factorLuminousIntensity >
 The UnitMultiply type is an alias of multiply calculation with two units. More...
 
template<typename Unit1 , typename Unit2 >
using UnitDivide = Unit< Unit1::factorLength - Unit2::factorLength, Unit1::factorMass - Unit2::factorMass, Unit1::factorTime - Unit2::factorTime, Unit1::factorCurrent - Unit2::factorCurrent, Unit1::factorTemperature - Unit2::factorTemperature, Unit1::factorAmountOfSubstance - Unit2::factorAmountOfSubstance, Unit1::factorLuminousIntensity - Unit2::factorLuminousIntensity >
 The UnitDivide type is an alias of divide calculation with two units. More...
 
template<typename U , int n>
using UnitPow = Unit< U::factorLength *n, U::factorMass *n, U::factorTime *n, U::factorCurrent *n, U::factorTemperature *n, U::factorAmountOfSubstance *n, U::factorLuminousIntensity *n >
 The UnitPow type is an alias of power calculation with two units. More...
 
template<typename U , int n>
using UnitRoot = Unit< U::factorLength/n, U::factorMass/n, U::factorTime/n, U::factorCurrent/n, U::factorTemperature/n, U::factorAmountOfSubstance/n, U::factorLuminousIntensity/n >
 The UnitRoot type is an alias of power calculation with two units. More...
 
Base Units

7 international base units.

typedef Unit< 0, 0, 0, 0, 0, 0, 0 > Scala
 The scala type of non-unit. More...
 
typedef Unit< 1, 0, 0, 0, 0, 0, 0 > Length
 Length unit, called meter, with symbol m. More...
 
typedef Unit< 0, 1, 0, 0, 0, 0, 0 > Mass
 Mass unit, called kilogram, with symbol kg. More...
 
typedef Unit< 0, 0, 1, 0, 0, 0, 0 > Time
 Time unit, called second, with symbol s. More...
 
typedef Unit< 0, 0, 0, 1, 0, 0, 0 > Current
 Electric current unit, called ampere, with symbol A. More...
 
typedef Unit< 0, 0, 0, 0, 1, 0, 0 > Temperature
 Thermodynamic temperature unit, called kelvin, with symbol K. More...
 
typedef Unit< 0, 0, 0, 0, 0, 1, 0 > AmountOfSubstance
 Amount of substance unit, called mole, with symbol mol. More...
 
typedef Unit< 0, 0, 0, 0, 0, 0, 1 > LuminousIntensity
 Luminous intensity unit, called candela, with symbol cd. More...
 
Derived Units

International System of Units derived from base units.

typedef UnitDivide< Length, TimeSpeed
 Speed unit, derived from $m/s$. More...
 
typedef UnitDivide< Speed, TimeAcceleration
 Acceleration unit, derived from $m/s^{2}$. More...
 
typedef UnitDivide< Scala, TimeFrenquency
 Frequence unit, called hertz, with symbol Hz, derived from $s^{-1}$. More...
 
typedef UnitMultiply< Mass, AccelerationForce
 Force unit, called newton, with symbol N, derived from $kg \cdot m \cdot s^{-2}$. More...
 
typedef UnitMultiply< Length, LengthArea
 Area unit, with symbol $m^{2}$. More...
 
typedef UnitMultiply< Area, LengthVolume
 Volume unit, with symbol $m^{3}$. More...
 
typedef UnitDivide< Force, AreaPressure
 Pressure unit, called pascal, with symbol Pa, derived from $N/m^{2}$ or $kg \cdot m^{-1} \cdot s^{-2}$. More...
 
typedef UnitMultiply< Force, LengthEnergy
 Enegy unit, called joule, with symbol J, derived from $N \cdot m$ or $kg \cdot m^{2} \cdot s^{-2}$. More...
 
typedef UnitDivide< Energy, TimePower
 Power unit, called watt, with symbol W, derived from $J/s$ or $kg \cdot m^{2} \cdot s^{-3}$. More...
 
typedef UnitMultiply< Time, CurrentCharge
 Charge unit, called coulomb, with symbol C, derived from $s \cdot A$. More...
 
typedef UnitDivide< Power, CurrentVoltage
 Voltage unit, called volt, with symbol V, derived from $W/A$ or $kg \cdot m^{2} \cdot s^{-3} \cdot A^{-1}$. More...
 
typedef UnitDivide< Charge, VoltageElelctricCapacitance
 Elelctric capacitance unit, called farad, with symbol F, derived from $C/V$ or $kg^{-1} \cdot m^{-2} \cdot s^{4} \cdot A^{2}$. More...
 
typedef UnitDivide< Voltage, CurrentElectricResistance
 Electric resistance unit, called ohm, with symbol Ω, derived from $V/A$ or $kg \cdot m^{2} \cdot s^{-3} \cdot A^{-2}$. More...
 
typedef UnitDivide< Scala, ElectricResistanceElelctricConductance
 Electric conductance unit, called simens, with symbol S, derived from $1/\Omega$ or $kg^{-1} \cdot m^{-2} \cdot s^{3} \cdot A^{2}$. More...
 
typedef UnitMultiply< Voltage, TimeMagneticFlux
 Magnetic flux unit, called webber, with symbol Wb**, derived from $V \cdot s$ or $kg \cdot m^{2} \cdot s^{-2} \cdot A^{-1}$. More...
 
typedef UnitDivide< MagneticFlux, AreaMagnetFluxDensity
 Magnet flux density unit, called tesla, with symbol T, derived from $Wb/m^{2}$ or $kg \cdot s^{-2} \cdot A^{-1}$. More...
 
typedef UnitDivide< MagneticFlux, CurrentInductance
 Electric unit, called henry, with symbol H, derived from $Wb/A$ or $kg \cdot m^{2} \cdot s^{-2} \cdot A^{-2}$. More...
 
typedef LuminousIntensity Luminous
 Luminous flux unit, called lumen, with symbol lm, derived from $cd \cdot sr$. More...
 
typedef UnitDivide< LuminousIntensity, AreaIlluminance
 Illuminance unit, called lux, with symbol ls, derived from $lm/m^{2}$ or $m^{-2} \cdot cd$. More...
 
typedef UnitDivide< Scala, TimeRadioactivity
 Radioactivity unit of decays per second, called becquerel, with symbol Bq derived from $s^{-1}$. More...
 
typedef UnitDivide< Energy, MassAbsorbedDose
 Absorbed dose unit of ionising radiation, called gray, with symbol Gy, derived from $J/kg$ or $m^{2} \cdot s^{-2}$. More...
 
typedef UnitDivide< Energy, MassEquivalentDose
 Equivalent dose unit of ionising radiation, called sievert, with symbol Sv, derived from $J/kg$ or $m^{2} \cdot s^{-2}$. More...
 
typedef UnitDivide< AmountOfSubstance, TimeCatalyticActivity
 Catalytic activity unit called katal, with symbol kat, derived from $mol \cdot s^{-1}$. More...
 

Detailed Description

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
struct Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >

The Unit struct is used to describe physical units.

Template Parameters
lengthPower factor of length unit.
massPower factor of length mass unit.
timePower factor of length time unit.
currentPower factor of length current unit.
temperaturePower factor of length temperature unit.
amountOfSubstancePower factor of amount_of_substance unit.
luminousIntensityPower factor of luminous_intensity unit.

This template use 7 international base units to describe all physical units, to guarantee strong-typed unit analysis.
Directly use this struct is not suggested, use UnitMultiply, UnitDivide, UnitPower and UnitRoot with typedef/using to generate derived unit with exisiting units.
sa DimensionalAnalysis, Quantity

Member Typedef Documentation

◆ type

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
using Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::type = Unit<length, mass, time, current, temperature, amountOfSubstance, luminousIntensity>

Type of the struct itself.

Friends And Related Function Documentation

◆ UnitMultiply

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
template<typename Unit1 , typename Unit2 >
using UnitMultiply = Unit< Unit1::factorLength + Unit2::factorLength, Unit1::factorMass + Unit2::factorMass, Unit1::factorTime + Unit2::factorTime, Unit1::factorCurrent + Unit2::factorCurrent, Unit1::factorTemperature + Unit2::factorTemperature, Unit1::factorAmountOfSubstance + Unit2::factorAmountOfSubstance, Unit1::factorLuminousIntensity + Unit2::factorLuminousIntensity >
related

The UnitMultiply type is an alias of multiply calculation with two units.

Template Parameters
Unit1First operand unit.
Unit2Second operand unit.

◆ UnitDivide

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
template<typename Unit1 , typename Unit2 >
using UnitDivide = Unit< Unit1::factorLength - Unit2::factorLength, Unit1::factorMass - Unit2::factorMass, Unit1::factorTime - Unit2::factorTime, Unit1::factorCurrent - Unit2::factorCurrent, Unit1::factorTemperature - Unit2::factorTemperature, Unit1::factorAmountOfSubstance - Unit2::factorAmountOfSubstance, Unit1::factorLuminousIntensity - Unit2::factorLuminousIntensity >
related

The UnitDivide type is an alias of divide calculation with two units.

Template Parameters
Unit1First operand unit.
Unit2Second operand unit.

◆ UnitPow

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
template<typename U , int n>
using UnitPow = Unit< U::factorLength * n, U::factorMass * n, U::factorTime * n, U::factorCurrent * n, U::factorTemperature * n, U::factorAmountOfSubstance * n, U::factorLuminousIntensity * n >
related

The UnitPow type is an alias of power calculation with two units.

Template Parameters
UOperand unit.
nFactor of power calculation.

◆ UnitRoot

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
template<typename U , int n>
using UnitRoot = Unit< U::factorLength / n, U::factorMass / n, U::factorTime / n, U::factorCurrent / n, U::factorTemperature / n, U::factorAmountOfSubstance / n, U::factorLuminousIntensity / n >
related

The UnitRoot type is an alias of power calculation with two units.

Template Parameters
UOperand unit.
nFactor of root calculation.

◆ Scala

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 0, 0, 0, 0, 0> Scala
related

The scala type of non-unit.

◆ Length

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<1, 0, 0, 0, 0, 0, 0> Length
related

Length unit, called meter, with symbol m.

◆ Mass

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 1, 0, 0, 0, 0, 0> Mass
related

Mass unit, called kilogram, with symbol kg.

◆ Time

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 1, 0, 0, 0, 0> Time
related

Time unit, called second, with symbol s.

◆ Current

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 0, 1, 0, 0, 0> Current
related

Electric current unit, called ampere, with symbol A.

◆ Temperature

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 0, 0, 1, 0, 0> Temperature
related

Thermodynamic temperature unit, called kelvin, with symbol K.

◆ AmountOfSubstance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 0, 0, 0, 1, 0> AmountOfSubstance
related

Amount of substance unit, called mole, with symbol mol.

◆ LuminousIntensity

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef Unit<0, 0, 0, 0, 0, 0, 1> LuminousIntensity
related

Luminous intensity unit, called candela, with symbol cd.

◆ Speed

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Length, Time> Speed
related

Speed unit, derived from $m/s$.

◆ Acceleration

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Speed, Time> Acceleration
related

Acceleration unit, derived from $m/s^{2}$.

◆ Frenquency

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Scala, Time> Frenquency
related

Frequence unit, called hertz, with symbol Hz, derived from $s^{-1}$.

◆ Force

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Mass, Acceleration> Force
related

Force unit, called newton, with symbol N, derived from $kg \cdot m \cdot s^{-2}$.

◆ Area

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Length, Length> Area
related

Area unit, with symbol $m^{2}$.

◆ Volume

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Area, Length> Volume
related

Volume unit, with symbol $m^{3}$.

◆ Pressure

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Force, Area> Pressure
related

Pressure unit, called pascal, with symbol Pa, derived from $N/m^{2}$ or $kg \cdot m^{-1} \cdot s^{-2}$.

◆ Energy

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Force, Length> Energy
related

Enegy unit, called joule, with symbol J, derived from $N \cdot m$ or $kg \cdot m^{2} \cdot s^{-2}$.

◆ Power

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Energy, Time> Power
related

Power unit, called watt, with symbol W, derived from $J/s$ or $kg \cdot m^{2} \cdot s^{-3}$.

◆ Charge

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Time, Current> Charge
related

Charge unit, called coulomb, with symbol C, derived from $s \cdot A$.

◆ Voltage

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Power, Current> Voltage
related

Voltage unit, called volt, with symbol V, derived from $W/A$ or $kg \cdot m^{2} \cdot s^{-3} \cdot A^{-1}$.

◆ ElelctricCapacitance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Charge, Voltage> ElelctricCapacitance
related

Elelctric capacitance unit, called farad, with symbol F, derived from $C/V$ or $kg^{-1} \cdot m^{-2} \cdot s^{4} \cdot A^{2}$.

◆ ElectricResistance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Voltage, Current> ElectricResistance
related

Electric resistance unit, called ohm, with symbol Ω, derived from $V/A$ or $kg \cdot m^{2} \cdot s^{-3} \cdot A^{-2}$.

◆ ElelctricConductance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Scala, ElectricResistance> ElelctricConductance
related

Electric conductance unit, called simens, with symbol S, derived from $1/\Omega$ or $kg^{-1} \cdot m^{-2} \cdot s^{3} \cdot A^{2}$.

◆ MagneticFlux

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitMultiply<Voltage, Time> MagneticFlux
related

Magnetic flux unit, called webber, with symbol Wb**, derived from $V \cdot s$ or $kg \cdot m^{2} \cdot s^{-2} \cdot A^{-1}$.

◆ MagnetFluxDensity

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<MagneticFlux, Area> MagnetFluxDensity
related

Magnet flux density unit, called tesla, with symbol T, derived from $Wb/m^{2}$ or $kg \cdot s^{-2} \cdot A^{-1}$.

◆ Inductance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<MagneticFlux, Current> Inductance
related

Electric unit, called henry, with symbol H, derived from $Wb/A$ or $kg \cdot m^{2} \cdot s^{-2} \cdot A^{-2}$.

◆ Luminous

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef LuminousIntensity Luminous
related

Luminous flux unit, called lumen, with symbol lm, derived from $cd \cdot sr$.

◆ Illuminance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<LuminousIntensity, Area> Illuminance
related

Illuminance unit, called lux, with symbol ls, derived from $lm/m^{2}$ or $m^{-2} \cdot cd$.

◆ Radioactivity

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Scala, Time> Radioactivity
related

Radioactivity unit of decays per second, called becquerel, with symbol Bq derived from $s^{-1}$.

◆ AbsorbedDose

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Energy, Mass> AbsorbedDose
related

Absorbed dose unit of ionising radiation, called gray, with symbol Gy, derived from $J/kg$ or $m^{2} \cdot s^{-2}$.

◆ EquivalentDose

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<Energy, Mass> EquivalentDose
related

Equivalent dose unit of ionising radiation, called sievert, with symbol Sv, derived from $J/kg$ or $m^{2} \cdot s^{-2}$.

◆ CatalyticActivity

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
typedef UnitDivide<AmountOfSubstance, Time> CatalyticActivity
related

Catalytic activity unit called katal, with symbol kat, derived from $mol \cdot s^{-1}$.

Member Data Documentation

◆ factors

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr std::tuple<int, int, int, int, int, int, int> Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factors
staticconstexpr
Initial value:
{
length, mass, time, current, temperature, amountOfSubstance, luminousIntensity
}

Power factors of 7 base units.

◆ factorLength

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorLength = length
staticconstexpr

Power factor of length unit.

◆ factorMass

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorMass = mass
staticconstexpr

Power factor of length mass unit.

◆ factorTime

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorTime = time
staticconstexpr

Power factor of length time unit.

◆ factorCurrent

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorCurrent = current
staticconstexpr

Power factor of length current unit.

◆ factorTemperature

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorTemperature = temperature
staticconstexpr

Power factor of length temperature unit.

◆ factorAmountOfSubstance

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorAmountOfSubstance = amountOfSubstance
staticconstexpr

Power factor of amount_of_substance unit unit.

◆ factorLuminousIntensity

template<int length, int mass, int time, int current, int temperature, int amountOfSubstance, int luminousIntensity>
constexpr int Dimensional::Unit< length, mass, time, current, temperature, amountOfSubstance, luminousIntensity >::factorLuminousIntensity = luminousIntensity
staticconstexpr

Power factor of luminous_intensity unit unit.


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