SI  2.5.4
A header only c++ library that provides type safety and user defined literals for handling physical values defined in the International System of Units.
substance.h
Go to the documentation of this file.
1 
12 #pragma once
13 #include "detail/number_parser.h"
14 #include "detail/unit.h"
15 #include "detail/unit_symbol.h"
16 
17 namespace SI {
18 
19 template <typename _type, typename _ratio>
21 
22 template <typename _type> using atto_mol_t = substance_t<_type, std::atto>;
23 template <typename _type> using femto_mol_t = substance_t<_type, std::femto>;
24 template <typename _type> using pico_mol_t = substance_t<_type, std::pico>;
25 template <typename _type> using nano_mol_t = substance_t<_type, std::nano>;
26 template <typename _type> using micro_mol_t = substance_t<_type, std::micro>;
27 template <typename _type> using milli_mol_t = substance_t<_type, std::milli>;
28 template <typename _type> using mol_t = substance_t<_type, std::ratio<1>>;
29 template <typename _type> using kilo_mol_t = substance_t<_type, std::kilo>;
30 template <typename _type> using mega_mol_t = substance_t<_type, std::mega>;
31 template <typename _type> using giga_mol_t = substance_t<_type, std::giga>;
32 template <typename _type> using tera_mol_t = substance_t<_type, std::tera>;
33 template <typename _type> using peta_mol_t = substance_t<_type, std::peta>;
34 template <typename _type> using exa_mol_t = substance_t<_type, std::exa>;
35 
36 // specialize unit_symbol for usage with stream operators
37 template <>
38 struct unit_symbol<'N', std::ratio<1>>
39  : SI::detail::unit_symbol_impl<'m', 'o', 'l'> {};
40 
41 template <typename _ratio>
42 struct unit_symbol<'N', _ratio>
43  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'm',
44  'o', 'l'> {};
45 
46 inline namespace literals {
47 
48 template <char... _digits> constexpr atto_mol_t<int64_t> operator""_amol() {
49  return atto_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
50 }
51 
52 template <char... _digits> constexpr femto_mol_t<int64_t> operator""_fmol() {
53  return femto_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
54 }
55 
56 template <char... _digits> constexpr pico_mol_t<int64_t> operator""_pmol() {
57  return pico_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
58 }
59 
60 template <char... _digits> constexpr nano_mol_t<int64_t> operator""_nmol() {
61  return nano_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
62 }
63 
64 template <char... _digits> constexpr micro_mol_t<int64_t> operator""_umol() {
65  return micro_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
66 }
67 
68 template <char... _digits> constexpr milli_mol_t<int64_t> operator""_mmol() {
69  return milli_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
70 }
71 
72 template <char... _digits> constexpr mol_t<int64_t> operator""_mol() {
73  return mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
74 }
75 
76 template <char... _digits> constexpr kilo_mol_t<int64_t> operator""_kmol() {
77  return kilo_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
78 }
79 
80 template <char... _digits> constexpr mega_mol_t<int64_t> operator""_Mmol() {
81  return mega_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
82 }
83 
84 template <char... _digits> constexpr giga_mol_t<int64_t> operator""_Gmol() {
85  return giga_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
86 }
87 
88 template <char... _digits> constexpr tera_mol_t<int64_t> operator""_Tmol() {
89  return tera_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
90 }
91 
92 template <char... _digits> constexpr peta_mol_t<int64_t> operator""_Pmol() {
93  return peta_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
94 }
95 
96 template <char... _digits> constexpr exa_mol_t<int64_t> operator""_Emol() {
97  return exa_mol_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
98 }
99 
100 constexpr atto_mol_t<long double> operator""_amol(long double value) {
101  return atto_mol_t<long double>{value};
102 }
103 
104 constexpr femto_mol_t<long double> operator""_fmol(long double value) {
105  return femto_mol_t<long double>{value};
106 }
107 
108 constexpr pico_mol_t<long double> operator""_pmol(long double value) {
109  return pico_mol_t<long double>{value};
110 }
111 
112 constexpr nano_mol_t<long double> operator""_nmol(long double value) {
113  return nano_mol_t<long double>{value};
114 }
115 
116 constexpr micro_mol_t<long double> operator""_umol(long double value) {
117  return micro_mol_t<long double>{value};
118 }
119 
120 constexpr milli_mol_t<long double> operator""_mmol(long double value) {
121  return milli_mol_t<long double>{value};
122 }
123 
124 constexpr mol_t<long double> operator""_mol(long double value) {
125  return mol_t<long double>{value};
126 }
127 
128 constexpr kilo_mol_t<long double> operator""_kmol(long double value) {
129  return kilo_mol_t<long double>{value};
130 }
131 
132 constexpr mega_mol_t<long double> operator""_Mmol(long double value) {
133  return mega_mol_t<long double>{value};
134 }
135 
136 constexpr giga_mol_t<long double> operator""_Gmol(long double value) {
137  return giga_mol_t<long double>{value};
138 }
139 
140 constexpr tera_mol_t<long double> operator""_Tmol(long double value) {
141  return tera_mol_t<long double>{value};
142 }
143 
144 constexpr peta_mol_t<long double> operator""_Pmol(long double value) {
145  return peta_mol_t<long double>{value};
146 }
147 
148 constexpr exa_mol_t<long double> operator""_Emol(long double value) {
149  return exa_mol_t<long double>{value};
150 }
151 
152 } // namespace literals
153 } // namespace SI
Definition: absorbed_dose.h:18
interface class for number
Definition: number_parser.h:111
Compile time string provider for conversion of unit types to strings.
Definition: unit_symbol.h:21
base template class for holding values of type _type to be multiplied with a ratio _ratio
Definition: unit.h:51
Base struct. Unusable needs template overloading.
Definition: unit_symbol.h:64