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