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.
force.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include "acceleration.h"
16 #include "detail/number_parser.h"
18 #include "detail/unit.h"
19 #include "mass.h"
20 
21 namespace SI {
22 template <typename _type, class _ratio = std::ratio<1>>
24 
26 template <typename _type> using atto_newton_t = force_t<_type, std::atto>;
27 template <typename _type> using femto_newton_t = force_t<_type, std::femto>;
28 template <typename _type> using pico_newton_t = force_t<_type, std::pico>;
29 template <typename _type> using nano_newton_t = force_t<_type, std::nano>;
30 template <typename _type> using micro_newton_t = force_t<_type, std::micro>;
31 template <typename _type> using milli_newton_t = force_t<_type, std::milli>;
32 template <typename _type> using newton_t = force_t<_type, std::ratio<1>>;
33 template <typename _type> using kilo_newton_t = force_t<_type, std::kilo>;
34 template <typename _type> using mega_newton_t = force_t<_type, std::mega>;
35 template <typename _type> using giga_newton_t = force_t<_type, std::giga>;
36 template <typename _type> using tera_newton_t = force_t<_type, std::tera>;
37 template <typename _type> using peta_newton_t = force_t<_type, std::peta>;
38 template <typename _type> using exa_newton_t = force_t<_type, std::exa>;
39 
40 // specialize unit_symbol for usage with stream operators
41 template <>
42 struct unit_symbol<'F', std::ratio<1>> : SI::detail::unit_symbol_impl<'N'> {};
43 
44 template <typename _ratio>
45 struct unit_symbol<'F', _ratio>
46  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value,
47  'N'> {};
48 
49 namespace detail {
51 }
52 
53 inline namespace literals {
54 template <char... _digits> constexpr atto_newton_t<int64_t> operator""_aN() {
55  return atto_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
56 }
57 
58 template <char... _digits> constexpr femto_newton_t<int64_t> operator""_fN() {
60  SI::detail::parsing::Number<_digits...>::value};
61 }
62 
63 template <char... _digits> constexpr pico_newton_t<int64_t> operator""_pN() {
64  return pico_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
65 }
66 
67 template <char... _digits> constexpr nano_newton_t<int64_t> operator""_nN() {
68  return nano_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
69 }
70 
71 template <char... _digits> constexpr micro_newton_t<int64_t> operator""_uN() {
73  SI::detail::parsing::Number<_digits...>::value};
74 }
75 
76 template <char... _digits> constexpr milli_newton_t<int64_t> operator""_mN() {
78  SI::detail::parsing::Number<_digits...>::value};
79 }
80 
81 template <char... _digits> constexpr newton_t<int64_t> operator""_N() {
82  return newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
83 }
84 
85 template <char... _digits> constexpr kilo_newton_t<int64_t> operator""_kN() {
86  return kilo_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
87 }
88 
89 template <char... _digits> constexpr mega_newton_t<int64_t> operator""_MN() {
90  return mega_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
91 }
92 
93 template <char... _digits> constexpr giga_newton_t<int64_t> operator""_GN() {
94  return giga_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
95 }
96 
97 template <char... _digits> constexpr tera_newton_t<int64_t> operator""_TN() {
98  return tera_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
99 }
100 
101 template <char... _digits> constexpr peta_newton_t<int64_t> operator""_PN() {
102  return peta_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
103 }
104 
105 template <char... _digits> constexpr exa_newton_t<int64_t> operator""_EN() {
106  return exa_newton_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
107 }
108 
109 constexpr atto_newton_t<long double> operator""_aN(long double value) {
110  return atto_newton_t<long double>{value};
111 }
112 
113 constexpr femto_newton_t<long double> operator""_fN(long double value) {
114  return femto_newton_t<long double>{value};
115 }
116 
117 constexpr pico_newton_t<long double> operator""_pN(long double value) {
118  return pico_newton_t<long double>{value};
119 }
120 
121 constexpr nano_newton_t<long double> operator""_nN(long double value) {
122  return nano_newton_t<long double>{value};
123 }
124 
125 constexpr micro_newton_t<long double> operator""_uN(long double value) {
126  return micro_newton_t<long double>{value};
127 }
128 
129 constexpr milli_newton_t<long double> operator""_mN(long double value) {
130  return milli_newton_t<long double>{value};
131 }
132 
133 constexpr newton_t<long double> operator""_N(long double value) {
134  return newton_t<long double>{value};
135 }
136 
137 constexpr kilo_newton_t<long double> operator""_kN(long double value) {
138  return kilo_newton_t<long double>{value};
139 }
140 
141 constexpr mega_newton_t<long double> operator""_MN(long double value) {
142  return mega_newton_t<long double>{value};
143 }
144 
145 constexpr giga_newton_t<long double> operator""_GN(long double value) {
146  return giga_newton_t<long double>{value};
147 }
148 
149 constexpr tera_newton_t<long double> operator""_TN(long double value) {
150  return tera_newton_t<long double>{value};
151 }
152 
153 constexpr peta_newton_t<long double> operator""_PN(long double value) {
154  return peta_newton_t<long double>{value};
155 }
156 
157 constexpr exa_newton_t<long double> operator""_EN(long double value) {
158  return exa_newton_t<long double>{value};
159 }
160 
161 } // namespace literals
162 } // namespace SI
Definition: absorbed_dose.h:18
#define BUILD_UNIT_FROM_MULTIPLICATION(RESULTING_UNIT, UNIT_LHS, UNIT_RHS)
Definition: operator_helpers.h:54
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