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.
electric_resistance.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "detail/number_parser.h"
16 #include "detail/unit.h"
17 #include "electric_current.h"
18 #include "electric_potential.h"
19 
20 namespace SI {
21 
24 template <typename _type, class _ratio = std::ratio<1>>
26 
28 template <typename _type>
30 template <typename _type>
32 template <typename _type>
34 template <typename _type>
36 template <typename _type>
38 template <typename _type>
40 template <typename _type>
42 template <typename _type>
44 template <typename _type>
46 template <typename _type>
48 template <typename _type>
50 template <typename _type>
52 template <typename _type>
54 
55 // specialize unit_symbol for usage with stream operators
56 template <>
57 struct unit_symbol<'O', std::ratio<1>>
58  : SI::detail::unit_symbol_impl<'O', 'h', 'm'> {};
59 
60 template <typename _ratio>
61 struct unit_symbol<'O', _ratio>
62  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'O',
63  'h', 'm'> {};
64 
65 namespace detail {
68 
69 template <typename _type, class _ratio = std::ratio<1>>
72 constexpr auto operator/(
73  const _type scalar,
74  const detail::unit_t<'G', std::ratio<1>, _type, _ratio> &conductance) {
76  scalar / conductance.value()};
77 }
78 } // namespace detail
79 
80 inline namespace literals {
81 template <char... _digits> constexpr atto_ohm_t<int64_t> operator""_aOhm() {
82  return atto_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
83 }
84 
85 template <char... _digits> constexpr femto_ohm_t<int64_t> operator""_fOhm() {
86  return femto_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
87 }
88 
89 template <char... _digits> constexpr pico_ohm_t<int64_t> operator""_pOhm() {
90  return pico_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
91 }
92 
93 template <char... _digits> constexpr nano_ohm_t<int64_t> operator""_nOhm() {
94  return nano_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
95 }
96 
97 template <char... _digits> constexpr micro_ohm_t<int64_t> operator""_uOhm() {
98  return micro_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
99 }
100 
101 template <char... _digits> constexpr milli_ohm_t<int64_t> operator""_mOhm() {
102  return milli_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
103 }
104 
105 template <char... _digits> constexpr ohm_t<int64_t> operator""_Ohm() {
106  return ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
107 }
108 
109 template <char... _digits> constexpr kilo_ohm_t<int64_t> operator""_kOhm() {
110  return kilo_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
111 }
112 
113 template <char... _digits> constexpr mega_ohm_t<int64_t> operator""_MOhm() {
114  return mega_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
115 }
116 
117 template <char... _digits> constexpr giga_ohm_t<int64_t> operator""_GOhm() {
118  return giga_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
119 }
120 
121 template <char... _digits> constexpr tera_ohm_t<int64_t> operator""_TOhm() {
122  return tera_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
123 }
124 
125 template <char... _digits> constexpr peta_ohm_t<int64_t> operator""_POhm() {
126  return peta_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
127 }
128 
129 template <char... _digits> constexpr exa_ohm_t<int64_t> operator""_EOhm() {
130  return exa_ohm_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
131 }
132 
133 constexpr atto_ohm_t<long double> operator""_aOhm(long double value) {
134  return atto_ohm_t<long double>{value};
135 }
136 
137 constexpr femto_ohm_t<long double> operator""_fOhm(long double value) {
138  return femto_ohm_t<long double>{value};
139 }
140 
141 constexpr pico_ohm_t<long double> operator""_pOhm(long double value) {
142  return pico_ohm_t<long double>{value};
143 }
144 
145 constexpr nano_ohm_t<long double> operator""_nOhm(long double value) {
146  return nano_ohm_t<long double>{value};
147 }
148 
149 constexpr micro_ohm_t<long double> operator""_uOhm(long double value) {
150  return micro_ohm_t<long double>{value};
151 }
152 
153 constexpr milli_ohm_t<long double> operator""_mOhm(long double value) {
154  return milli_ohm_t<long double>{value};
155 }
156 
157 constexpr ohm_t<long double> operator""_Ohm(long double value) {
158  return ohm_t<long double>{value};
159 }
160 
161 constexpr kilo_ohm_t<long double> operator""_kOhm(long double value) {
162  return kilo_ohm_t<long double>{value};
163 }
164 
165 constexpr mega_ohm_t<long double> operator""_MOhm(long double value) {
166  return mega_ohm_t<long double>{value};
167 }
168 
169 constexpr giga_ohm_t<long double> operator""_GOhm(long double value) {
170  return giga_ohm_t<long double>{value};
171 }
172 
173 constexpr tera_ohm_t<long double> operator""_TOhm(long double value) {
174  return tera_ohm_t<long double>{value};
175 }
176 
177 constexpr peta_ohm_t<long double> operator""_POhm(long double value) {
178  return peta_ohm_t<long double>{value};
179 }
180 
181 constexpr exa_ohm_t<long double> operator""_EOhm(long double value) {
182  return exa_ohm_t<long double>{value};
183 }
184 
185 } // namespace literals
186 } // namespace SI
BUILD_UNIT_FROM_DIVISION(electric_conductance_t, electric_current_t, electric_potential_t) template< typename _type
constexpr auto operator/(const _type &lhs, const unit_t< _symbol, _exponent, _rhs_type, _ratio > &rhs)
Definition: unit.h:491
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
constexpr _type value() const
returns the stored value as raw type
Definition: unit.h:100
Base struct. Unusable needs template overloading.
Definition: unit_symbol.h:64