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
velocity.h
Go to the documentation of this file.
1
12#pragma once
13
15
17#include "detail/unit.h"
18#include "frequency.h"
19#include "length.h"
20#include "time.h"
21
22namespace SI {
23
25template <typename _type, typename _ratio>
26using velocity_t = detail::unit_t<'v', std::ratio<1>, _type, _ratio>;
27
28template <typename _type, typename _ratio>
29using velocity_squared_t = detail::unit_t<'v', std::ratio<2>, _type, _ratio>;
30
31template <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
36template <typename _type>
39
40template <typename _type>
42
43namespace detail {
46} // namespace detail
47
48// specialize unit_symbol for usage with stream operators
49template <>
50struct unit_symbol<'v', std::ratio<1>>
51 : SI::detail::unit_symbol_impl<'m', '/', 's'> {};
52
53template <>
54struct unit_symbol<'v', std::ratio_divide<std::kilo, std::ratio<3600, 1>>::type>
55 : SI::detail::unit_symbol_impl<'k', 'm', '/', 'h'> {};
56
57template <typename _ratio>
58struct unit_symbol<'v', _ratio>
59 : SI::detail::unit_symbol_impl<SI::detail::ratio_prefix<_ratio>::value, 'm',
60 '/', 's'> {};
61inline namespace literals {
62
63template <char... _digits> constexpr speed_of_light_t<int64_t> operator""_c() {
65 SI::detail::parsing::Number<_digits...>::value};
66}
67
68constexpr speed_of_light_t<long double> operator""_c(long double value) {
70}
71
72template <char... _digits>
73constexpr metre_per_second_t<int64_t> operator""_m_p_s() {
75 SI::detail::parsing::Number<_digits...>::value};
76}
77
78template <char... _digits>
79constexpr kilometre_per_hour_t<int64_t> operator""_km_p_h() {
81 SI::detail::parsing::Number<_digits...>::value};
82}
83
84constexpr metre_per_second_t<long double> operator""_m_p_s(long double value) {
86}
87
88constexpr kilometre_per_hour_t<long double>
89operator""_km_p_h(long double value) {
91}
92
93} // namespace literals
94
95} // namespace SI
Definition absorbed_dose.h:18
#define BUILD_UNIT_FROM_DIVISION(RESULTING_UNIT_T, DIVIDEND_UNIT_T, DIVISOR_UNIT_T)
Definition operator_helpers.h:22
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