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.
power.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 "detail/unit_symbol.h"
18 #include "energy.h"
19 
20 namespace SI {
21 template <typename _type, class _ratio = std::ratio<1>>
23 
25 template <typename _type> using atto_watt_t = power_t<_type, std::atto>;
26 template <typename _type> using femto_watt_t = power_t<_type, std::femto>;
27 template <typename _type> using pico_watt_t = power_t<_type, std::pico>;
28 template <typename _type> using nano_watt_t = power_t<_type, std::nano>;
29 template <typename _type> using micro_watt_t = power_t<_type, std::micro>;
30 template <typename _type> using milli_watt_t = power_t<_type, std::milli>;
31 template <typename _type> using watt_t = power_t<_type, std::ratio<1>>;
32 template <typename _type> using kilo_watt_t = power_t<_type, std::kilo>;
33 template <typename _type> using mega_watt_t = power_t<_type, std::mega>;
34 template <typename _type> using giga_watt_t = power_t<_type, std::giga>;
35 template <typename _type> using tera_watt_t = power_t<_type, std::tera>;
36 template <typename _type> using peta_watt_t = power_t<_type, std::peta>;
37 template <typename _type> using exa_watt_t = power_t<_type, std::exa>;
38 
39 // specialize unit_symbol for usage with stream operators
40 template <>
41 struct unit_symbol<'P', std::ratio<1>> : SI::detail::unit_symbol_impl<'W'> {};
42 
43 template <typename _ratio>
44 struct unit_symbol<'P', _ratio>
45  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value,
46  'W'> {};
47 
48 namespace detail {
50 }
51 
52 inline namespace literals {
53 template <char... _digits> constexpr atto_watt_t<int64_t> operator""_aW() {
54  return atto_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
55 }
56 
57 template <char... _digits> constexpr femto_watt_t<int64_t> operator""_fW() {
58  return femto_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
59 }
60 
61 template <char... _digits> constexpr pico_watt_t<int64_t> operator""_pW() {
62  return pico_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
63 }
64 
65 template <char... _digits> constexpr nano_watt_t<int64_t> operator""_nW() {
66  return nano_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
67 }
68 
69 template <char... _digits> constexpr micro_watt_t<int64_t> operator""_uW() {
70  return micro_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
71 }
72 
73 template <char... _digits> constexpr milli_watt_t<int64_t> operator""_mW() {
74  return milli_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
75 }
76 
77 template <char... _digits> constexpr watt_t<int64_t> operator""_W() {
78  return watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
79 }
80 
81 template <char... _digits> constexpr kilo_watt_t<int64_t> operator""_kW() {
82  return kilo_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
83 }
84 
85 template <char... _digits> constexpr mega_watt_t<int64_t> operator""_MW() {
86  return mega_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
87 }
88 
89 template <char... _digits> constexpr giga_watt_t<int64_t> operator""_GW() {
90  return giga_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
91 }
92 
93 template <char... _digits> constexpr tera_watt_t<int64_t> operator""_TW() {
94  return tera_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
95 }
96 
97 template <char... _digits> constexpr peta_watt_t<int64_t> operator""_PW() {
98  return peta_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
99 }
100 
101 template <char... _digits> constexpr exa_watt_t<int64_t> operator""_EW() {
102  return exa_watt_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
103 }
104 
105 constexpr atto_watt_t<long double> operator""_aW(long double value) {
106  return atto_watt_t<long double>{value};
107 }
108 
109 constexpr femto_watt_t<long double> operator""_fW(long double value) {
110  return femto_watt_t<long double>{value};
111 }
112 
113 constexpr pico_watt_t<long double> operator""_pW(long double value) {
114  return pico_watt_t<long double>{value};
115 }
116 
117 constexpr nano_watt_t<long double> operator""_nW(long double value) {
118  return nano_watt_t<long double>{value};
119 }
120 
121 constexpr micro_watt_t<long double> operator""_uW(long double value) {
122  return micro_watt_t<long double>{value};
123 }
124 
125 constexpr milli_watt_t<long double> operator""_mW(long double value) {
126  return milli_watt_t<long double>{value};
127 }
128 
129 constexpr watt_t<long double> operator""_W(long double value) {
130  return watt_t<long double>{value};
131 }
132 
133 constexpr kilo_watt_t<long double> operator""_kW(long double value) {
134  return kilo_watt_t<long double>{value};
135 }
136 
137 constexpr mega_watt_t<long double> operator""_MW(long double value) {
138  return mega_watt_t<long double>{value};
139 }
140 
141 constexpr giga_watt_t<long double> operator""_GW(long double value) {
142  return giga_watt_t<long double>{value};
143 }
144 
145 constexpr tera_watt_t<long double> operator""_TW(long double value) {
146  return tera_watt_t<long double>{value};
147 }
148 
149 constexpr peta_watt_t<long double> operator""_PW(long double value) {
150  return peta_watt_t<long double>{value};
151 }
152 
153 constexpr exa_watt_t<long double> operator""_EW(long double value) {
154  return exa_watt_t<long double>{value};
155 }
156 
157 } // namespace literals
158 } // namespace SI
BUILD_UNIT_FROM_DIVISION(electric_conductance_t, electric_current_t, electric_potential_t) template< typename _type
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