Cpp Utilities 1.2.3
Public Types | Public Member Functions | Related Functions | List of all members
Dimensional::Quantity< T, U, Ratio > Class Template Reference

The Quantity struct is used to describe arithmetic values with units. More...

#include <DimensionalAnalysis.hpp>

Public Types

using type = Quantity< T, U, Ratio >
 Self type for this quantity struct. More...
 
using value_type = T
 Value type for this quantity struct. More...
 
using unit_type = U
 Unit type for this quantity struct. More...
 
using ratio_type = Ratio
 Ratio type for this quantity struct. More...
 

Public Member Functions

 Quantity (T x=0)
 Default constructor. More...
 
 Quantity (const Quantity< T, U, Ratio > &other)
 Copy constructor. More...
 
template<typename OtherRatio >
 Quantity (const Quantity< T, U, OtherRatio > &other)
 Copy constructor from same quantity type with different ratio. More...
 
value () const
 Get underlying value of the quantity, value represented with current unit and ratio will be returned. More...
 
void set_value (T value)
 Set underlying value of the quantity. More...
 
standard_value () const
 Get standard value of the quantity, Ratio is reverted to std::ratio<1>. More...
 
void set_standard_value (T value)
 Get standard value of the quantity, Ratio is reverted to std::ratio<1>. More...
 
template<typename OtherRatio >
Quantity< T, U, Ratio > & operator+= (const Quantity< T, U, OtherRatio > &other)
 Add & assignment operator overload, add value from same type with maybe different ratio, operand value will be converted by ratio_type before performing add. More...
 
Quantity< T, U, Ratio > & operator= (const Quantity< T, U, Ratio > &other)
 Assisgnment operator overload. More...
 
template<typename OtherRatio >
Quantity< T, U, Ratio > & operator= (const Quantity< T, U, OtherRatio > &other)
 Assisgnment operator overload, assign value from same type but different ratio, operand value will be converted by ratio_type before performing assignment. More...
 
template<typename OtherRatio >
bool operator== (const Quantity< T, U, OtherRatio > &other) const
 Equality operator overload, value will be convered to same ratio before comparison. More...
 
template<typename OtherRatio >
bool operator!= (const Quantity< T, U, OtherRatio > &other) const
 Inequality operator overload, value will be convered to same ratio before comparison. More...
 
template<typename OtherRatio >
bool operator< (const Quantity< T, U, OtherRatio > &other) const
 Less than operator overload, value will be convered to same ratio before comparison. More...
 
template<typename OtherRatio >
bool operator<= (const Quantity< T, U, OtherRatio > &other) const
 Less or equal operator overload, value will be convered to same ratio before comparison. More...
 
template<typename OtherRatio >
bool operator> (const Quantity< T, U, OtherRatio > &other) const
 Larger than operator overload, value will be convered to same ratio before comparison. More...
 
template<typename OtherRatio >
bool operator>= (const Quantity< T, U, OtherRatio > &other) const
 Larger or equal operator overload, value will be convered to same ratio before comparison. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename U , typename Ratio1 , typename Ratio2 >
Quantity< T, U, Ratio1 > operator+ (Quantity< T, U, Ratio1 > lhs, Quantity< T, U, Ratio2 > rhs)
 Plus operator overload, values will be converted to same ratio before calculation, both inputs should have same value type and unit type. More...
 
template<typename T , typename U , typename Ratio1 , typename Ratio2 >
Quantity< T, U, Ratio1 > operator- (Quantity< T, U, Ratio1 > &lhs, Quantity< T, U, Ratio2 > rhs)
 Subtract operator overload, values will be converted to same ratio before calculation, both inputs should have same value type and unit type. More...
 
template<typename T , typename Unit1 , typename Ratio1 , typename Unit2 , typename Ratio2 >
Quantity< T, UnitMultiply< Unit1, Unit2 >, Ratio1 > operator* (Quantity< T, Unit1, Ratio1 > lhs, Quantity< T, Unit2, Ratio2 > rhs)
 Multiply operator overload, values will be converted to same ratio before calculation, inputs can have different unit type, a new unit type will be generated. More...
 
template<typename T , typename Unit1 , typename Ratio1 , typename Unit2 , typename Ratio2 >
Quantity< T, UnitDivide< Unit1, Unit2 >, Ratio1 > operator/ (Quantity< T, Unit1, Ratio1 > lhs, Quantity< T, Unit2, Ratio2 > rhs)
 Divide operator overload, values will be converted to same ratio before calculation, inputs can have different unit type, a new unit type will be generated. More...
 
template<int factor, typename T , typename U , typename Ratio >
Quantity< T, UnitPow< U, factor >, std::ratio< 1 > > pow (const Quantity< T, U, Ratio > &x)
 Power calculation, performed both on value and unit, ratio will be casted to std::ratio<1>. More...
 
template<int factor, typename T , typename U , typename Ratio >
Quantity< T, UnitRoot< U, factor >, std::ratio< 1 > > root (const Quantity< T, U, Ratio > &x)
 Root calculation, performed both on value and unit, ratio will be casted to std::ratio<1>. More...
 
template<typename NewRatio , typename T , typename U , typename Ratio >
Quantity< T, U, NewRatio > quantity_cast (Quantity< T, U, Ratio > x)
 Cast a quantity to another ratio, value will be converted too. Sample code for convert to standard value: b = quantity_cast<std::ratio<1>>(a); More...
 
Common Ratio

Common ratios for calculation.

typedef std::ratio< 80813362, 25723692 > ratio_PI
 Ratio to display π in approximate fraction, with high presion up to $3.14159266096017653069$. More...
 
typedef std::ratio_divide< ratio_PI, std::ratio< 180 > > ratio_degree
 Ratio to convert degree into radian, using equation $rad = degree * \frac{pi}{180}$. More...
 
Chinese Units

Ratios for Chinese units of mass and length.

typedef std::ratio< 500, 1 > ratio_length_li
 Ratio to convert to meter. $1 li = 15 yin = 500 m$. More...
 
typedef std::ratio_divide< ratio_length_li, std::ratio< 15 > > ratio_yin
 Ratio to convert to meter. $1 yin = \frac{1}{15} li = 10 zhang = 33.\overline{3} m$. More...
 
typedef std::ratio_divide< ratio_yin, std::ratio< 10 > > ratio_zhang
 Ratio to convert to meter. $1 zhang = \frac{1}{10} yin = 10 chi = 3.\overline{3} m$. More...
 
typedef std::ratio_divide< ratio_zhang, std::ratio< 2 > > ratio_xun
 Ratio to convert to meter. $1 xun = 1/2 zhang = 5 chi = 1.\overline{6} m$. More...
 
typedef std::ratio_divide< ratio_zhang, std::ratio< 10 > > ratio_chi
 Ratio to convert to meter. $1 chi = 33.\overline{3} cm$. More...
 
typedef std::ratio_divide< ratio_chi, std::ratio< 10 > > ratio_cun
 Ratio to convert to meter. $1 cun = \frac{1}{10} chi = 3.\overline{3} cm$. More...
 
typedef std::ratio_divide< ratio_cun, std::ratio< 10 > > ratio_length_fen
 Ratio to convert to meter. $1 fen = \frac{1}{10} cun = 3.\overline{3} mm$. More...
 
typedef std::ratio_divide< ratio_length_fen, std::ratio< 10 > > ratio_length_li2
 Ratio to convert to meter. $1 li = \frac{1}{10} fen = 333.\overline{3} um$. More...
 
typedef std::ratio_divide< ratio_length_li2, std::ratio< 10 > > ratio_length_hao
 Ratio to convert to meter. $1 hao = \frac{1}{10} li = 33.\overline{3} um$. More...
 
typedef std::ratio_divide< ratio_length_hao, std::ratio< 10 > > ratio_length_si
 Ratio to convert to meter. $1 si = \frac{1}{10} hao = 3.\overline{3} um$. More...
 
typedef std::ratio_divide< ratio_length_si, std::ratio< 10 > > ratio_length_hu
 Ratio to convert to meter. $1 hu = \frac{1}{10} si = 333.\overline{3} nm$. More...
 
typedef std::ratio< 200000, 3 > ratio_qing
 Ratio to convert to suqaremeter. $1 qing = 100 mu = 66666.\overline{6} m^{2}$. More...
 
typedef std::ratio< 2000, 3 > ratio_mu
 Ratio to convert to suqaremeter. $1 mu = 240 gong = 666.\overline{6} m^{2}$. More...
 
typedef std::ratio_divide< ratio_mu, std::ratio< 240 > > ratio_gong
 Ratio to convert to suqaremeter. $1 gong = 1 xun^{2} = 2.\overline{7} m^{2}$. More...
 
typedef std::ratio< 50 > ratio_dan
 Ratio to convert to kilogram. $1 dan = 50 kg$. More...
 
typedef std::ratio< 1, 2 > ratio_jin
 Ratio to convert to kilogram, also called market carry. $1 jin = 500 g catty$. More...
 
typedef std::ratio_divide< ratio_jin, std::ratio< 10 > > ratio_liang
 Ratio to convert to kilogram. $1 liang = \frac{1}{10} jin = 50 g$. More...
 
typedef std::ratio_divide< ratio_liang, std::ratio< 10 > > ratio_qian
 Ratio to convert to kilogram. $1 qian = \frac{1}{10} liang = 5 g$. More...
 
typedef std::ratio_divide< ratio_qian, std::ratio< 10 > > ratio_mass_fen
 Ratio to convert to kilogram. $1 fen = \frac{1}{10} qian = 500 mg$. More...
 
typedef std::ratio_divide< ratio_mass_fen, std::ratio< 10 > > ratio_mass_li
 Ratio to convert to kilogram. $1 li = \frac{1}{10} fen = 50 mg$. More...
 
typedef std::ratio_divide< ratio_mass_li, std::ratio< 10 > > ratio_mass_hao
 Ratio to convert to kilogram. $1 hao = \frac{1}{10} li = 5 mg$. More...
 
typedef std::ratio_divide< ratio_mass_hao, std::ratio< 10 > > ratio_mass_si
 Ratio to convert to kilogram. $1 si = \frac{1}{10} hao = 500 ug$. More...
 
typedef std::ratio_divide< ratio_mass_si, std::ratio< 10 > > ratio_mass_hu
 Ratio to convert to kilogram. $1 hu = \frac{1}{10} si = 50 ug$. More...
 
Yard Pound

Ratios for International Avoirdupois System of yard and pound units.

typedef std::ratio_multiply< std::ratio< 1609344ll, 1000000ll >, std::kilo > ratio_mile
 Ratio to convert to meter. $1 mile = 1.609344 km$. More...
 
typedef std::ratio_divide< ratio_mile, std::ratio< 8 > > ratio_furlong
 Ratio to convert to meter. $1 furlong = 201.168 m$. More...
 
typedef std::ratio_divide< ratio_furlong, std::ratio< 10 > > ratio_chain
 Ratio to convert to meter. $1 chain = \frac{1}{10} furlong = \frac{1}{80} mile = 20.1168 m$. More...
 
typedef std::ratio_divide< ratio_chain, std::ratio< 22 > > ratio_yard
 Ratio to convert to meter. $1 yard = \frac{1}{22} chain = \frac{1}{1760} mile = 0.9144 m$. More...
 
typedef std::ratio_divide< ratio_yard, std::ratio< 16 > > ratio_nail
 Ratio to convert to meter. $1 nail = \frac{1}{16} yard = \frac{9}{4} inch = 5.715 cm$. More...
 
typedef std::ratio_divide< ratio_yard, std::ratio< 3 > > ratio_feet
 Ratio to convert to meter. $1 feet = \frac{1}{3} yard = 30.48 cm$. More...
 
typedef std::ratio_divide< ratio_feet, std::ratio< 12 > > ratio_inch
 Ratio to convert to meter. $1 inch = \frac{1}{12} feet = 2.54 cm$. More...
 
typedef std::ratio_divide< ratio_inch, std::ratio< 6 > > ratio_pica
 Ratio to convert to meter, with symbol pc. $1 pica = \frac{1}{6} inch = 4.2\overline{3} mm$. More...
 
typedef std::ratio_divide< ratio_pica, std::ratio< 12 > > ratio_point
 Ratio to convert to meter, with symbol 'pt'. $1 point = \frac{1}{12} pica = 0.352\overline{7} mm$. More...
 
typedef std::ratio< 10160469088, 10000000 > ratio_longton
 Ratio to convert to kilogram. $1 longton = 2240 pound = 1016.0469088 kg$. More...
 
typedef std::ratio< 90718474, 100000 > ratio_shortton
 Ratio to convert to kilogram. $1 shortton = 2000 pound = 907.18474 kg$. More...
 
typedef std::ratio< 5080234544, 100000000 > ratio_long_hundredweight
 Ratio to convert to kilogram. $1 long\ hundredweight = 112 pound = 50.80234544 kg$. More...
 
typedef std::ratio< 45359237, 1000000 > ratio_short_hundredweight
 Ratio to convert to kilogram. $1 short\ hundredweight = 100 pound = 45.359237 kg$. More...
 
typedef std::ratio< 45359237, 100000000 > ratio_pound
 Ratio to convert to kilogram. $1 pound = 0.45359237 kg$. More...
 
typedef std::ratio_divide< ratio_pound, std::ratio< 16 > > ratio_ounce
 Ratio to convert to kilogram. $1 ounce = \frac{1}{16} pound = 28.349523125 g$. More...
 
typedef std::ratio_divide< ratio_ounce, std::ratio< 16 > > ratio_drachm
 Ratio to convert to kilogram. $1 drachm = \frac{1}{16} ounce = 1.7718451953125 g$. More...
 
typedef std::ratio_multiply< std::ratio< 6479891, 100000ll >, std::micro > ratio_grain
 Ratio to convert to kilogram. $1 grain = 64.79891 mg$. More...
 
Imperial Units

Imperial units of mass and volume

typedef ratio_long_hundredweight ratio_en_hundredweight
 Ratio to convert to kilogram. $1 Imperial\ hundredweight = 8 stone = 112 pound = 50.80234544 kg$. More...
 
typedef std::ratio_multiply< ratio_pound, std::ratio< 28 > > ratio_en_quarter
 Ratio to convert to kilogram. $1 quarter = 2 stone = 28 pound = 12.70058636 kg$. More...
 
typedef std::ratio_multiply< ratio_pound, std::ratio< 14 > > ratio_en_stone
 Ratio to convert to kilogram. $1 stone = 14 pound = 6.35029318 kg$. More...
 
typedef std::ratio_multiply< std::ratio< 35516328125ll, 10000000000ll >, std::micro > ratio_en_fluid_dram
 Ratio to convert to cubicmeter. $1 fluid\ dram = 3.5516328125 mL$. More...
 
typedef std::ratio_multiply< ratio_en_fluid_dram, std::ratio< 8 > > ratio_en_fluid_ounce
 Ratio to convert to cubicmeter. $1 fluid\ ounce = 8 fluind\ dram = 28.4130625 mL$. More...
 
typedef std::ratio_multiply< ratio_en_fluid_ounce, std::ratio< 5 > > ratio_en_gill
 Ratio to convert to cubicmeter. $1 gill = 5 fluid\ ounce = 142.0653125 mL$. More...
 
typedef std::ratio_multiply< ratio_en_gill, std::ratio< 2 > > ratio_en_cup
 Ratio to convert to cubicmeter. $1 cup = 2 gill = 284.130625 mL$. More...
 
typedef std::ratio_multiply< ratio_en_cup, std::ratio< 2 > > ratio_en_pint
 Ratio to convert to cubicmeter. $1 pint = 2 cup = 568.26125 mL$. More...
 
typedef std::ratio_multiply< ratio_en_pint, std::ratio< 2 > > ratio_en_quart
 Ratio to convert to cubicmeter. $1 quart = 2 pint = 1.1365225 L$. More...
 
typedef std::ratio_multiply< ratio_en_quart, std::ratio< 4 > > ratio_en_gallon
 Ratio to convert to cubicmeter. $1 gallon = 4 quart = 4.54609 L$. More...
 
typedef std::ratio_multiply< ratio_en_gallon, std::ratio< 2 > > ratio_en_peck
 Ratio to convert to cubicmeter. $1 peck = 2 gallon = 9.09218 L$. More...
 
typedef std::ratio_multiply< ratio_en_peck, std::ratio< 4 > > ratio_en_bushel
 Ratio to convert to cubicmeter. $1 bushel = 4 peck = 36.36872 L$. More...
 
US Units

US units of mass and volume

typedef ratio_short_hundredweight ratio_us_hundredweight
 Ratio to convert to kilogram $1 US hundredweight = 100 pound = 45.359237 kg$. More...
 
typedef std::ratio_multiply< std::ratio< 36966911953125ll, 10000000000000ll >, std::micro > ratio_us_fluid_dram
 Ratio to convert to cubicmeter. $1 fluid\ dram = 3.6966911953125 mL$. More...
 
typedef std::ratio_multiply< ratio_us_fluid_dram, std::ratio< 8 > > ratio_us_fluid_ounce
 Ratio to convert to cubicmeter. $1 fluid\ ounce = 8 fluid\ dram = 29.5735295625 mL$. More...
 
typedef std::ratio_divide< ratio_us_fluid_ounce, std::ratio< 6 > > ratio_us_teaspoons
 Ratio to convert to cubicmeter. $1 teaspoons = \frac{1}{6} fluid\ ounce = 4.92892159375 mL$. More...
 
typedef std::ratio_divide< ratio_us_fluid_ounce, std::ratio< 2 > > ratio_us_tablespoons
 Ratio to convert to cubicmeter. $1 tablespoons = \frac{1}{2} fluid\ ounce = 14.78676478125 mL$. More...
 
typedef std::ratio_multiply< ratio_us_fluid_ounce, std::ratio< 4 > > ratio_us_gill
 Ratio to convert to cubicmeter. $1 gill = 4 fluid\ ounce = 118.29411825 mL$. More...
 
typedef std::ratio_multiply< ratio_us_gill, std::ratio< 2 > > ratio_us_cup
 Ratio to convert to cubicmeter. $1 cup = 2 gill = 236.5882365 mL$. More...
 
typedef std::ratio_multiply< ratio_us_cup, std::ratio< 2 > > ratio_us_pint
 Ratio to convert to cubicmeter. $1 pint = 2 cup = 473.176473 mL$. More...
 
typedef std::ratio_multiply< ratio_us_pint, std::ratio< 2 > > ratio_us_quart
 Ratio to convert to cubicmeter. $1 quart = 2 pint = 946.352946 mL$. More...
 
typedef std::ratio_multiply< ratio_us_quart, std::ratio< 4 > > ratio_us_gallon
 Ratio to convert to cubicmeter. $1 gallon = 4 quart = 3.785411784 L$. More...
 
typedef std::ratio_multiply< std::ratio< 5506104713575ll, 10000000000000ll >, std::milli > ratio_us_dry_pint
 Ratio to convert to cubicmeter. $1 dry\ pint = 0.5506104713575 L$. More...
 
typedef std::ratio_multiply< ratio_us_dry_pint, std::ratio< 2 > > ratio_us_dry_quart
 Ratio to convert to cubicmeter. $1 dry\ quart = 2 dry\ pint = 1.101220942715 L$. More...
 
typedef std::ratio_multiply< ratio_us_dry_quart, std::ratio< 4 > > ratio_us_dry_gallon
 Ratio to convert to cubicmeter. $1 dry\ gallon = 4 dry\ quart = 4.40488377086 L$. More...
 
typedef std::ratio_multiply< ratio_us_dry_gallon, std::ratio< 2 > > ratio_us_dry_peck
 Ratio to convert to cubicmeter. $1 dry\ peck = 2 dry\ gallon = 8.80976754172 L$. More...
 
typedef std::ratio_multiply< ratio_us_dry_peck, std::ratio< 4 > > ratio_us_bushel
 Ratio to convert to cubicmeter. $1 bushel = 4 dry\ peck = 35.23907016688 L$. More...
 

Detailed Description

template<typename T, typename U, typename Ratio = std::ratio<1>>
class Dimensional::Quantity< T, U, Ratio >

The Quantity struct is used to describe arithmetic values with units.

Template Parameters
TArithmetic type for value.
UUnit type for this physical quantity.
RatioConversion ratio for nonstandard units such as feet or yard.

This template guarantee strong-typed safe calculation of physical values.
Variables with different unit cannot add, subtract and compare with each other. Multiply, divide, power, root calculation will generate value with unit.
Value is allowd to be described with different Ratio. Calculation with different ratios is safe, and result has same Ratio of first operand.

See also
Dimensional Analysis, Unit

Member Typedef Documentation

◆ type

template<typename T , typename U , typename Ratio = std::ratio<1>>
using Dimensional::Quantity< T, U, Ratio >::type = Quantity<T, U, Ratio>

Self type for this quantity struct.

◆ value_type

template<typename T , typename U , typename Ratio = std::ratio<1>>
using Dimensional::Quantity< T, U, Ratio >::value_type = T

Value type for this quantity struct.

◆ unit_type

template<typename T , typename U , typename Ratio = std::ratio<1>>
using Dimensional::Quantity< T, U, Ratio >::unit_type = U

Unit type for this quantity struct.

◆ ratio_type

template<typename T , typename U , typename Ratio = std::ratio<1>>
using Dimensional::Quantity< T, U, Ratio >::ratio_type = Ratio

Ratio type for this quantity struct.

Constructor & Destructor Documentation

◆ Quantity() [1/3]

template<typename T , typename U , typename Ratio = std::ratio<1>>
Dimensional::Quantity< T, U, Ratio >::Quantity ( x = 0)
inlineexplicit

Default constructor.

Parameters
xInitial value, default is 0.

◆ Quantity() [2/3]

template<typename T , typename U , typename Ratio = std::ratio<1>>
Dimensional::Quantity< T, U, Ratio >::Quantity ( const Quantity< T, U, Ratio > &  other)
inline

Copy constructor.

Parameters
otherOperand to be copied.

◆ Quantity() [3/3]

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
Dimensional::Quantity< T, U, Ratio >::Quantity ( const Quantity< T, U, OtherRatio > &  other)
inline

Copy constructor from same quantity type with different ratio.

Template Parameters
OtherRatioratio of input operand.
Parameters
otherOperand to be copied.

Member Function Documentation

◆ value()

template<typename T , typename U , typename Ratio = std::ratio<1>>
T Dimensional::Quantity< T, U, Ratio >::value ( ) const
inline

Get underlying value of the quantity, value represented with current unit and ratio will be returned.

Warning
Return value is under the Ratio and may not be standard value.
Returns
underlying Value with Ratio converted.

◆ set_value()

template<typename T , typename U , typename Ratio = std::ratio<1>>
void Dimensional::Quantity< T, U, Ratio >::set_value ( value)
inline

Set underlying value of the quantity.

Parameters
valueValue represented by Ratio.
Warning
value is under the Ratio and may not be standard value.

◆ standard_value()

template<typename T , typename U , typename Ratio = std::ratio<1>>
T Dimensional::Quantity< T, U, Ratio >::standard_value ( ) const
inline

Get standard value of the quantity, Ratio is reverted to std::ratio<1>.

Returns
Standard value with Ratio reverted to std::ratio<1>.

◆ set_standard_value()

template<typename T , typename U , typename Ratio = std::ratio<1>>
void Dimensional::Quantity< T, U, Ratio >::set_standard_value ( value)
inline

Get standard value of the quantity, Ratio is reverted to std::ratio<1>.

Returns
Standard value with Ratio reverted to std::ratio<1>.

◆ operator+=()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
Quantity< T, U, Ratio > & Dimensional::Quantity< T, U, Ratio >::operator+= ( const Quantity< T, U, OtherRatio > &  other)
inline

Add & assignment operator overload, add value from same type with maybe different ratio, operand value will be converted by ratio_type before performing add.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOperand to assign from.
Returns
Reference to self with value added.

◆ operator=() [1/2]

template<typename T , typename U , typename Ratio = std::ratio<1>>
Quantity< T, U, Ratio > & Dimensional::Quantity< T, U, Ratio >::operator= ( const Quantity< T, U, Ratio > &  other)
inline

Assisgnment operator overload.

Parameters
otherOperand to assign from.
Returns
Reference to self with value assigned.

◆ operator=() [2/2]

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
Quantity< T, U, Ratio > & Dimensional::Quantity< T, U, Ratio >::operator= ( const Quantity< T, U, OtherRatio > &  other)
inline

Assisgnment operator overload, assign value from same type but different ratio, operand value will be converted by ratio_type before performing assignment.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOperand to assign from.
Returns
Reference to self with value assigned.

◆ operator==()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator== ( const Quantity< T, U, OtherRatio > &  other) const
inline

Equality operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

◆ operator!=()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator!= ( const Quantity< T, U, OtherRatio > &  other) const
inline

Inequality operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

◆ operator<()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator< ( const Quantity< T, U, OtherRatio > &  other) const
inline

Less than operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

◆ operator<=()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator<= ( const Quantity< T, U, OtherRatio > &  other) const
inline

Less or equal operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

◆ operator>()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator> ( const Quantity< T, U, OtherRatio > &  other) const
inline

Larger than operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

◆ operator>=()

template<typename T , typename U , typename Ratio = std::ratio<1>>
template<typename OtherRatio >
bool Dimensional::Quantity< T, U, Ratio >::operator>= ( const Quantity< T, U, OtherRatio > &  other) const
inline

Larger or equal operator overload, value will be convered to same ratio before comparison.

Template Parameters
OtherRatioRatio of input operand.
Parameters
otherOther operand to be compared.
Returns
Boolean value for result of comparison.

Friends And Related Function Documentation

◆ ratio_PI

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<80813362, 25723692> ratio_PI
related

Ratio to display π in approximate fraction, with high presion up to $3.14159266096017653069$.

◆ ratio_degree

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_PI, std::ratio<180> > ratio_degree
related

Ratio to convert degree into radian, using equation $rad = degree * \frac{pi}{180}$.

◆ ratio_length_li

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<500, 1> ratio_length_li
related

Ratio to convert to meter. $1 li = 15 yin = 500 m$.

◆ ratio_yin

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_length_li, std::ratio<15> > ratio_yin
related

Ratio to convert to meter. $1 yin = \frac{1}{15} li = 10 zhang = 33.\overline{3} m$.

◆ ratio_zhang

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_yin, std::ratio<10> > ratio_zhang
related

Ratio to convert to meter. $1 zhang = \frac{1}{10} yin = 10 chi = 3.\overline{3} m$.

◆ ratio_xun

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_zhang, std::ratio<2> > ratio_xun
related

Ratio to convert to meter. $1 xun = 1/2 zhang = 5 chi = 1.\overline{6} m$.

◆ ratio_chi

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_zhang, std::ratio<10> > ratio_chi
related

Ratio to convert to meter. $1 chi = 33.\overline{3} cm$.

◆ ratio_cun

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_chi, std::ratio<10> > ratio_cun
related

Ratio to convert to meter. $1 cun = \frac{1}{10} chi = 3.\overline{3} cm$.

◆ ratio_length_fen

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_cun, std::ratio<10> > ratio_length_fen
related

Ratio to convert to meter. $1 fen = \frac{1}{10} cun = 3.\overline{3} mm$.

◆ ratio_length_li2

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_length_fen, std::ratio<10> > ratio_length_li2
related

Ratio to convert to meter. $1 li = \frac{1}{10} fen = 333.\overline{3} um$.

◆ ratio_length_hao

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_length_li2, std::ratio<10> > ratio_length_hao
related

Ratio to convert to meter. $1 hao = \frac{1}{10} li = 33.\overline{3} um$.

◆ ratio_length_si

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_length_hao, std::ratio<10> > ratio_length_si
related

Ratio to convert to meter. $1 si = \frac{1}{10} hao = 3.\overline{3} um$.

◆ ratio_length_hu

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_length_si, std::ratio<10> > ratio_length_hu
related

Ratio to convert to meter. $1 hu = \frac{1}{10} si = 333.\overline{3} nm$.

◆ ratio_qing

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<200000, 3> ratio_qing
related

Ratio to convert to suqaremeter. $1 qing = 100 mu = 66666.\overline{6} m^{2}$.

◆ ratio_mu

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<2000, 3> ratio_mu
related

Ratio to convert to suqaremeter. $1 mu = 240 gong = 666.\overline{6} m^{2}$.

◆ ratio_gong

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mu, std::ratio<240> > ratio_gong
related

Ratio to convert to suqaremeter. $1 gong = 1 xun^{2} = 2.\overline{7} m^{2}$.

◆ ratio_dan

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<50> ratio_dan
related

Ratio to convert to kilogram. $1 dan = 50 kg$.

◆ ratio_jin

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<1, 2> ratio_jin
related

Ratio to convert to kilogram, also called market carry. $1 jin = 500 g catty$.

◆ ratio_liang

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_jin, std::ratio<10> > ratio_liang
related

Ratio to convert to kilogram. $1 liang = \frac{1}{10} jin = 50 g$.

◆ ratio_qian

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_liang, std::ratio<10> > ratio_qian
related

Ratio to convert to kilogram. $1 qian = \frac{1}{10} liang = 5 g$.

◆ ratio_mass_fen

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_qian, std::ratio<10> > ratio_mass_fen
related

Ratio to convert to kilogram. $1 fen = \frac{1}{10} qian = 500 mg$.

◆ ratio_mass_li

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mass_fen, std::ratio<10> > ratio_mass_li
related

Ratio to convert to kilogram. $1 li = \frac{1}{10} fen = 50 mg$.

◆ ratio_mass_hao

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mass_li, std::ratio<10> > ratio_mass_hao
related

Ratio to convert to kilogram. $1 hao = \frac{1}{10} li = 5 mg$.

◆ ratio_mass_si

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mass_hao, std::ratio<10> > ratio_mass_si
related

Ratio to convert to kilogram. $1 si = \frac{1}{10} hao = 500 ug$.

◆ ratio_mass_hu

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mass_si, std::ratio<10> > ratio_mass_hu
related

Ratio to convert to kilogram. $1 hu = \frac{1}{10} si = 50 ug$.

◆ ratio_mile

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<std::ratio<1609344ll, 1000000ll>, std::kilo> ratio_mile
related

Ratio to convert to meter. $1 mile = 1.609344 km$.

◆ ratio_furlong

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_mile, std::ratio<8> > ratio_furlong
related

Ratio to convert to meter. $1 furlong = 201.168 m$.

◆ ratio_chain

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_furlong, std::ratio<10> > ratio_chain
related

Ratio to convert to meter. $1 chain = \frac{1}{10} furlong = \frac{1}{80} mile = 20.1168 m$.

◆ ratio_yard

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_chain, std::ratio<22> > ratio_yard
related

Ratio to convert to meter. $1 yard = \frac{1}{22} chain = \frac{1}{1760} mile = 0.9144 m$.

◆ ratio_nail

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_yard, std::ratio<16> > ratio_nail
related

Ratio to convert to meter. $1 nail = \frac{1}{16} yard = \frac{9}{4} inch = 5.715 cm$.

◆ ratio_feet

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_yard, std::ratio<3> > ratio_feet
related

Ratio to convert to meter. $1 feet = \frac{1}{3} yard = 30.48 cm$.

◆ ratio_inch

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_feet, std::ratio<12> > ratio_inch
related

Ratio to convert to meter. $1 inch = \frac{1}{12} feet = 2.54 cm$.

◆ ratio_pica

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_inch, std::ratio<6> > ratio_pica
related

Ratio to convert to meter, with symbol pc. $1 pica = \frac{1}{6} inch = 4.2\overline{3} mm$.

◆ ratio_point

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_pica, std::ratio<12> > ratio_point
related

Ratio to convert to meter, with symbol 'pt'. $1 point = \frac{1}{12} pica = 0.352\overline{7} mm$.

◆ ratio_longton

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<10160469088, 10000000> ratio_longton
related

Ratio to convert to kilogram. $1 longton = 2240 pound = 1016.0469088 kg$.

◆ ratio_shortton

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<90718474, 100000> ratio_shortton
related

Ratio to convert to kilogram. $1 shortton = 2000 pound = 907.18474 kg$.

◆ ratio_long_hundredweight

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<5080234544, 100000000> ratio_long_hundredweight
related

Ratio to convert to kilogram. $1 long\ hundredweight = 112 pound = 50.80234544 kg$.

◆ ratio_short_hundredweight

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<45359237, 1000000> ratio_short_hundredweight
related

Ratio to convert to kilogram. $1 short\ hundredweight = 100 pound = 45.359237 kg$.

◆ ratio_pound

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio<45359237, 100000000> ratio_pound
related

Ratio to convert to kilogram. $1 pound = 0.45359237 kg$.

◆ ratio_ounce

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_pound, std::ratio<16> > ratio_ounce
related

Ratio to convert to kilogram. $1 ounce = \frac{1}{16} pound = 28.349523125 g$.

◆ ratio_drachm

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_ounce, std::ratio<16> > ratio_drachm
related

Ratio to convert to kilogram. $1 drachm = \frac{1}{16} ounce = 1.7718451953125 g$.

◆ ratio_grain

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<std::ratio<6479891, 100000ll>, std::micro> ratio_grain
related

Ratio to convert to kilogram. $1 grain = 64.79891 mg$.

◆ ratio_en_hundredweight

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef ratio_long_hundredweight ratio_en_hundredweight
related

Ratio to convert to kilogram. $1 Imperial\ hundredweight = 8 stone = 112 pound = 50.80234544 kg$.

◆ ratio_en_quarter

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_pound, std::ratio<28> > ratio_en_quarter
related

Ratio to convert to kilogram. $1 quarter = 2 stone = 28 pound = 12.70058636 kg$.

◆ ratio_en_stone

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_pound, std::ratio<14> > ratio_en_stone
related

Ratio to convert to kilogram. $1 stone = 14 pound = 6.35029318 kg$.

◆ ratio_en_fluid_dram

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<std::ratio<35516328125ll, 10000000000ll>, std::micro> ratio_en_fluid_dram
related

Ratio to convert to cubicmeter. $1 fluid\ dram = 3.5516328125 mL$.

◆ ratio_en_fluid_ounce

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_fluid_dram, std::ratio<8> > ratio_en_fluid_ounce
related

Ratio to convert to cubicmeter. $1 fluid\ ounce = 8 fluind\ dram = 28.4130625 mL$.

◆ ratio_en_gill

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_fluid_ounce, std::ratio<5> > ratio_en_gill
related

Ratio to convert to cubicmeter. $1 gill = 5 fluid\ ounce = 142.0653125 mL$.

◆ ratio_en_cup

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_gill, std::ratio<2> > ratio_en_cup
related

Ratio to convert to cubicmeter. $1 cup = 2 gill = 284.130625 mL$.

◆ ratio_en_pint

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_cup, std::ratio<2> > ratio_en_pint
related

Ratio to convert to cubicmeter. $1 pint = 2 cup = 568.26125 mL$.

◆ ratio_en_quart

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_pint, std::ratio<2> > ratio_en_quart
related

Ratio to convert to cubicmeter. $1 quart = 2 pint = 1.1365225 L$.

◆ ratio_en_gallon

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_quart, std::ratio<4> > ratio_en_gallon
related

Ratio to convert to cubicmeter. $1 gallon = 4 quart = 4.54609 L$.

◆ ratio_en_peck

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_gallon, std::ratio<2> > ratio_en_peck
related

Ratio to convert to cubicmeter. $1 peck = 2 gallon = 9.09218 L$.

◆ ratio_en_bushel

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_en_peck, std::ratio<4> > ratio_en_bushel
related

Ratio to convert to cubicmeter. $1 bushel = 4 peck = 36.36872 L$.

◆ ratio_us_hundredweight

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef ratio_short_hundredweight ratio_us_hundredweight
related

Ratio to convert to kilogram $1 US hundredweight = 100 pound = 45.359237 kg$.

◆ ratio_us_fluid_dram

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<std::ratio<36966911953125ll, 10000000000000ll>, std::micro> ratio_us_fluid_dram
related

Ratio to convert to cubicmeter. $1 fluid\ dram = 3.6966911953125 mL$.

◆ ratio_us_fluid_ounce

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_fluid_dram, std::ratio<8> > ratio_us_fluid_ounce
related

Ratio to convert to cubicmeter. $1 fluid\ ounce = 8 fluid\ dram = 29.5735295625 mL$.

◆ ratio_us_teaspoons

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_us_fluid_ounce, std::ratio<6> > ratio_us_teaspoons
related

Ratio to convert to cubicmeter. $1 teaspoons = \frac{1}{6} fluid\ ounce = 4.92892159375 mL$.

◆ ratio_us_tablespoons

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_divide<ratio_us_fluid_ounce, std::ratio<2> > ratio_us_tablespoons
related

Ratio to convert to cubicmeter. $1 tablespoons = \frac{1}{2} fluid\ ounce = 14.78676478125 mL$.

◆ ratio_us_gill

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_fluid_ounce, std::ratio<4> > ratio_us_gill
related

Ratio to convert to cubicmeter. $1 gill = 4 fluid\ ounce = 118.29411825 mL$.

◆ ratio_us_cup

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_gill, std::ratio<2> > ratio_us_cup
related

Ratio to convert to cubicmeter. $1 cup = 2 gill = 236.5882365 mL$.

◆ ratio_us_pint

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_cup, std::ratio<2> > ratio_us_pint
related

Ratio to convert to cubicmeter. $1 pint = 2 cup = 473.176473 mL$.

◆ ratio_us_quart

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_pint, std::ratio<2> > ratio_us_quart
related

Ratio to convert to cubicmeter. $1 quart = 2 pint = 946.352946 mL$.

◆ ratio_us_gallon

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_quart, std::ratio<4> > ratio_us_gallon
related

Ratio to convert to cubicmeter. $1 gallon = 4 quart = 3.785411784 L$.

◆ ratio_us_dry_pint

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<std::ratio<5506104713575ll, 10000000000000ll>, std::milli> ratio_us_dry_pint
related

Ratio to convert to cubicmeter. $1 dry\ pint = 0.5506104713575 L$.

◆ ratio_us_dry_quart

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_dry_pint, std::ratio<2> > ratio_us_dry_quart
related

Ratio to convert to cubicmeter. $1 dry\ quart = 2 dry\ pint = 1.101220942715 L$.

◆ ratio_us_dry_gallon

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_dry_quart, std::ratio<4> > ratio_us_dry_gallon
related

Ratio to convert to cubicmeter. $1 dry\ gallon = 4 dry\ quart = 4.40488377086 L$.

◆ ratio_us_dry_peck

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_dry_gallon, std::ratio<2> > ratio_us_dry_peck
related

Ratio to convert to cubicmeter. $1 dry\ peck = 2 dry\ gallon = 8.80976754172 L$.

◆ ratio_us_bushel

template<typename T , typename U , typename Ratio = std::ratio<1>>
typedef std::ratio_multiply<ratio_us_dry_peck, std::ratio<4> > ratio_us_bushel
related

Ratio to convert to cubicmeter. $1 bushel = 4 dry\ peck = 35.23907016688 L$.

◆ operator+()

template<typename T , typename U , typename Ratio1 , typename Ratio2 >
Quantity< T, U, Ratio1 > operator+ ( Quantity< T, U, Ratio1 >  lhs,
Quantity< T, U, Ratio2 >  rhs 
)
related

Plus operator overload, values will be converted to same ratio before calculation, both inputs should have same value type and unit type.

Template Parameters
TValue type of operands.
UUnit of operands.
Ratio1Ratio of first operand.
Ratio2Ratio of second operand.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
Calculation result represened with Ratio1.

◆ operator-()

template<typename T , typename U , typename Ratio1 , typename Ratio2 >
Quantity< T, U, Ratio1 > operator- ( Quantity< T, U, Ratio1 > &  lhs,
Quantity< T, U, Ratio2 >  rhs 
)
related

Subtract operator overload, values will be converted to same ratio before calculation, both inputs should have same value type and unit type.

Template Parameters
TValue type of operands.
UUnit of operands.
Ratio1Ratio of first operand.
Ratio2Ratio of second operand.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
Calculation result represened with Ratio1.

◆ operator*()

template<typename T , typename Unit1 , typename Ratio1 , typename Unit2 , typename Ratio2 >
Quantity< T, UnitMultiply< Unit1, Unit2 >, Ratio1 > operator* ( Quantity< T, Unit1, Ratio1 >  lhs,
Quantity< T, Unit2, Ratio2 >  rhs 
)
related

Multiply operator overload, values will be converted to same ratio before calculation, inputs can have different unit type, a new unit type will be generated.

Template Parameters
TValue type of operands.
Unit1Unit of first operand.
Ratio1Ratio of first operand.
Unit2Unit of second operand.
Ratio2Ratio of second operand.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
Calculation result represened with Ratio1.

◆ operator/()

template<typename T , typename Unit1 , typename Ratio1 , typename Unit2 , typename Ratio2 >
Quantity< T, UnitDivide< Unit1, Unit2 >, Ratio1 > operator/ ( Quantity< T, Unit1, Ratio1 >  lhs,
Quantity< T, Unit2, Ratio2 >  rhs 
)
related

Divide operator overload, values will be converted to same ratio before calculation, inputs can have different unit type, a new unit type will be generated.

Template Parameters
TValue type of operands.
Unit1Unit of first operand.
Ratio1Ratio of first operand.
Unit2Unit of second operand.
Ratio2Ratio of second operand.
Parameters
lhsFirst operand.
rhsSecond operand.
Returns
Calculation result represened with Ratio1.

◆ pow()

template<int factor, typename T , typename U , typename Ratio >
Quantity< T, UnitPow< U, factor >, std::ratio< 1 > > pow ( const Quantity< T, U, Ratio > &  x)
related

Power calculation, performed both on value and unit, ratio will be casted to std::ratio<1>.

Template Parameters
factorFactor of power calculation.
TValue type of operands.
UUnit of operand.
RatioRatio of operand.
Parameters
xQuantity operand.
Returns
Calculation result with power performed both on value and unit.

◆ root()

template<int factor, typename T , typename U , typename Ratio >
Quantity< T, UnitRoot< U, factor >, std::ratio< 1 > > root ( const Quantity< T, U, Ratio > &  x)
related

Root calculation, performed both on value and unit, ratio will be casted to std::ratio<1>.

Template Parameters
factorFactor of root calculation.
TValue type of operands.
UUnit of operand.
RatioRatio of operand.
Parameters
xQuantity operand.
Returns
Calculation result with root performed both on value and unit.

◆ quantity_cast()

template<typename NewRatio , typename T , typename U , typename Ratio >
Quantity< T, U, NewRatio > quantity_cast ( Quantity< T, U, Ratio >  x)
related

Cast a quantity to another ratio, value will be converted too. Sample code for convert to standard value: b = quantity_cast<std::ratio<1>>(a);

Template Parameters
NewRatioRatio to be cast to.
TValue type of input.
UUnit of input.
RatioRatio of input.
Parameters
xOperand to be cast.
Returns
New quantity cast to NewRatio.

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