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.
velocity.h
Go to the documentation of this file.
1 
12 #pragma once
13 
15 
16 #include "detail/number_parser.h"
17 #include "detail/unit.h"
18 #include "frequency.h"
19 #include "length.h"
20 #include "time.h"
21 
22 namespace SI {
23 
25 template <typename _type, typename _ratio>
27 
28 template <typename _type, typename _ratio>
30 
31 template <typename _type>
33 
34 // ratio is calculated, so it gets reduced depending on the compiler
35 // so that 1_km/1_h results the same type as 1_km_p_h
36 template <typename _type>
39 
40 template <typename _type>
42 
43 namespace detail {
46 } // namespace detail
47 
48 // specialize unit_symbol for usage with stream operators
49 template <>
50 struct unit_symbol<'v', std::ratio<1>>
51  : SI::detail::unit_symbol_impl<'m', '/', 's'> {};
52 
53 template <>
54 struct unit_symbol<'v', std::ratio_divide<std::kilo, std::ratio<3600, 1>>::type>
55  : SI::detail::unit_symbol_impl<'k', 'm', '/', 'h'> {};
56 
57 template <typename _ratio>
58 struct unit_symbol<'v', _ratio>
59  : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'm',
60  '/', 's'> {};
61 inline namespace literals {
62 
63 template <char... _digits> constexpr speed_of_light_t<int64_t> operator""_c() {
65  SI::detail::parsing::Number<_digits...>::value};
66 }
67 
68 constexpr speed_of_light_t<long double> operator""_c(long double value) {
69  return speed_of_light_t<long double>{value};
70 }
71 
72 template <char... _digits>
73 constexpr metre_per_second_t<int64_t> operator""_m_p_s() {
75  SI::detail::parsing::Number<_digits...>::value};
76 }
77 
78 template <char... _digits>
79 constexpr kilometre_per_hour_t<int64_t> operator""_km_p_h() {
81  SI::detail::parsing::Number<_digits...>::value};
82 }
83 
84 constexpr metre_per_second_t<long double> operator""_m_p_s(long double value) {
85  return metre_per_second_t<long double>{value};
86 }
87 
88 constexpr kilometre_per_hour_t<long double>
89 operator""_km_p_h(long double value) {
91 }
92 
93 } // namespace literals
94 
95 } // 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