SyDEVS
v0.6.7
Multiscale Simulation and Systems Modeling Library
|
A template which represents Standard International (SI) units inclusing the base units such as grams, meters, and seconds, and derived units such as meters-per-second-squared. More...
#include <units.h>
Public Types | |
enum | { g_ = g, m_ = m, s_ = s, A_ = A, K_ = K, mol_ = mol, cd_ = cd } |
Public Member Functions | |
constexpr | units ()=default |
Constructs a unit object. More... | |
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_> | |
constexpr units< g+g_, m+m_, s+s_, A+A_, K+K_, mol+mol_, cd+cd_ > | operator* (units< g_, m_, s_, A_, K_, mol_, cd_ > rhs) const |
Combines two units into one as if the unit on the left were multiplied by that on the right. More... | |
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_> | |
constexpr units< g-g_, m-m_, s-s_, A-A_, K-K_, mol-mol_, cd-cd_ > | operator/ (units< g_, m_, s_, A_, K_, mol_, cd_ > rhs) const |
Combines two units into one as if the unit on the left were divided by that on the right. More... | |
A template which represents Standard International (SI) units inclusing the base units such as grams, meters, and seconds, and derived units such as meters-per-second-squared.
The units
type can be used to specify an SI unit at compile time as a combination of the 7 base units: grams (g), meters (m), seconds (s), Amperes (A), Kelvin (L), mols (mol), and candelas (cd).
A type alias is defined for dimensionless quantities.
There is also a type alias for each of the base units:
For each base unit, the associated value is defined as a constant.
There are two ways to expressed SI derived units. The first is using the template constructor, where each template parameter is the exponent of the corresponding base unit.
The second approach employs the base unit values in conjunction with multiplication and division operators and decltype
.
It is important to note that the units
class treats grams, not kilograms, as the base unit for mass. This affects derived quantities such as Newtons.
anonymous enum |
|
default |
Constructs a unit
object.
|
inline |
Combines two units into one as if the unit on the left were multiplied by that on the right.
|
inline |
Combines two units into one as if the unit on the left were divided by that on the right.