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.
frequency.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "detail/unit.h"
15 #include "detail/unit_symbol.h"
16 #include "time.h"
17 
18 namespace SI {
20 template <typename _type, class _ratio = std::ratio<1>>
21 using frequency_t = detail::time_base_t<std::ratio<-1>, _type, _ratio>;
22 
24 template <typename _type> using atto_hertz_t = frequency_t<_type, std::atto>;
25 template <typename _type> using femto_hertz_t = frequency_t<_type, std::femto>;
26 template <typename _type> using pico_hertz_t = frequency_t<_type, std::pico>;
27 template <typename _type> using nano_hertz_t = frequency_t<_type, std::nano>;
28 template <typename _type> using micro_hertz_t = frequency_t<_type, std::micro>;
29 template <typename _type> using milli_hertz_t = frequency_t<_type, std::milli>;
30 template <typename _type> using hertz_t = frequency_t<_type, std::ratio<1>>;
31 template <typename _type> using kilo_hertz_t = frequency_t<_type, std::kilo>;
32 template <typename _type> using mega_hertz_t = frequency_t<_type, std::mega>;
33 template <typename _type> using giga_hertz_t = frequency_t<_type, std::giga>;
34 template <typename _type> using tera_hertz_t = frequency_t<_type, std::tera>;
35 template <typename _type> using peta_hertz_t = frequency_t<_type, std::peta>;
36 template <typename _type> using exa_hertz_t = frequency_t<_type, std::exa>;
37 
38 // specialize unit_symbol for usage with stream operators
39 template <>
40 struct unit_symbol<'T', std::ratio<1>, std::ratio<-1>>
41  : SI::detail::unit_symbol_impl<'H', 'z'> {};
42 
43 template <typename _ratio>
44 struct unit_symbol<'T', _ratio, std::ratio<-1>>
45  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'H',
46  'z'> {};
47 
48 inline namespace literals {
49 template <char... _digits> constexpr atto_hertz_t<int64_t> operator""_aHz() {
50  return atto_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
51 }
52 
53 template <char... _digits> constexpr femto_hertz_t<int64_t> operator""_fHz() {
54  return femto_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
55 }
56 
57 template <char... _digits> constexpr pico_hertz_t<int64_t> operator""_pHz() {
58  return pico_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
59 }
60 
61 template <char... _digits> constexpr nano_hertz_t<int64_t> operator""_nHz() {
62  return nano_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
63 }
64 
65 template <char... _digits> constexpr micro_hertz_t<int64_t> operator""_uHz() {
66  return micro_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
67 }
68 
69 template <char... _digits> constexpr milli_hertz_t<int64_t> operator""_mHz() {
70  return milli_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
71 }
72 
73 template <char... _digits> constexpr hertz_t<int64_t> operator""_Hz() {
74  return hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
75 }
76 
77 template <char... _digits> constexpr kilo_hertz_t<int64_t> operator""_kHz() {
78  return kilo_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
79 }
80 
81 template <char... _digits> constexpr mega_hertz_t<int64_t> operator""_MHz() {
82  return mega_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
83 }
84 
85 template <char... _digits> constexpr giga_hertz_t<int64_t> operator""_GHz() {
86  return giga_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
87 }
88 
89 template <char... _digits> constexpr tera_hertz_t<int64_t> operator""_THz() {
90  return tera_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
91 }
92 
93 template <char... _digits> constexpr peta_hertz_t<int64_t> operator""_PHz() {
94  return peta_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
95 }
96 
97 template <char... _digits> constexpr exa_hertz_t<int64_t> operator""_EHz() {
98  return exa_hertz_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
99 }
100 
101 constexpr atto_hertz_t<long double> operator""_aHz(long double value) {
102  return atto_hertz_t<long double>{value};
103 }
104 
105 constexpr femto_hertz_t<long double> operator""_fHz(long double value) {
106  return femto_hertz_t<long double>{value};
107 }
108 
109 constexpr pico_hertz_t<long double> operator""_pHz(long double value) {
110  return pico_hertz_t<long double>{value};
111 }
112 
113 constexpr nano_hertz_t<long double> operator""_nHz(long double value) {
114  return nano_hertz_t<long double>{value};
115 }
116 
117 constexpr micro_hertz_t<long double> operator""_uHz(long double value) {
118  return micro_hertz_t<long double>{value};
119 }
120 
121 constexpr milli_hertz_t<long double> operator""_mHz(long double value) {
122  return milli_hertz_t<long double>{value};
123 }
124 
125 constexpr hertz_t<long double> operator""_Hz(long double value) {
126  return hertz_t<long double>{value};
127 }
128 
129 constexpr kilo_hertz_t<long double> operator""_kHz(long double value) {
130  return kilo_hertz_t<long double>{value};
131 }
132 
133 constexpr mega_hertz_t<long double> operator""_MHz(long double value) {
134  return mega_hertz_t<long double>{value};
135 }
136 
137 constexpr giga_hertz_t<long double> operator""_GHz(long double value) {
138  return giga_hertz_t<long double>{value};
139 }
140 
141 constexpr tera_hertz_t<long double> operator""_THz(long double value) {
142  return tera_hertz_t<long double>{value};
143 }
144 
145 constexpr peta_hertz_t<long double> operator""_PHz(long double value) {
146  return peta_hertz_t<long double>{value};
147 }
148 
149 constexpr exa_hertz_t<long double> operator""_EHz(long double value) {
150  return exa_hertz_t<long double>{value};
151 }
152 
153 } // namespace literals
154 } // 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