SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
units.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYDEVS_UNITS_H_
3 #define SYDEVS_UNITS_H_
4 
5 #include <sydevs/core/scale.h>
6 
7 namespace sydevs {
8 
9 
78 template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
79 struct units
80 {
81  constexpr units() = default;
82 
83  enum {
84  g_ = g,
85  m_ = m,
86  s_ = s,
87  A_ = A,
88  K_ = K,
89  mol_ = mol,
90  cd_ = cd,
91  };
92 
97  template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
99  {
101  }
102 
107  template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
108  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
109  {
110  return units<g - g_, m - m_, s - s_, A - A_, K - K_, mol - mol_, cd - cd_>();
111  }
112 };
113 
114 
123 
124 
125 constexpr auto _1 = no_units();
126 constexpr auto _g = grams();
127 constexpr auto _m = meters();
128 constexpr auto _s = seconds();
129 constexpr auto _A = amperes();
130 constexpr auto _K = kelvins();
131 constexpr auto _mol = moles();
132 constexpr auto _cd = candelas();
133 
134 
135 } // namespace
136 
137 #endif
Kelvins exponent.
Definition: units.h:88
Moles exponent.
Definition: units.h:89
units< 0, 0, 0, 0, 0, 0, 0 > no_units
Definition: units.h:115
units< 0, 0, 0, 0, 0, 0, 1 > candelas
Definition: units.h:122
constexpr auto _cd
Definition: units.h:132
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...
Definition: units.h:108
constexpr auto _mol
Definition: units.h:131
units< 0, 0, 1, 0, 0, 0, 0 > seconds
Definition: units.h:118
constexpr auto _g
Definition: units.h:126
Meters exponent.
Definition: units.h:85
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...
Definition: units.h:98
constexpr auto _s
Definition: units.h:128
constexpr auto _K
Definition: units.h:130
units< 0, 0, 0, 1, 0, 0, 0 > amperes
Definition: units.h:119
Grams exponent.
Definition: units.h:84
constexpr auto _A
Definition: units.h:129
constexpr units()=default
Constructs a unit object.
units< 0, 0, 0, 0, 0, 1, 0 > moles
Definition: units.h:121
Seconds exponent.
Definition: units.h:86
A template which represents Standard International (SI) units inclusing the base units such as grams...
Definition: units.h:79
units< 0, 0, 0, 0, 1, 0, 0 > kelvins
Definition: units.h:120
Amperes exponent.
Definition: units.h:87
constexpr auto _m
Definition: units.h:127
Candelas exponent.
Definition: units.h:90
units< 1, 0, 0, 0, 0, 0, 0 > grams
Definition: units.h:116
units< 0, 1, 0, 0, 0, 0, 0 > meters
Definition: units.h:117
constexpr auto _1
Definition: units.h:125