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
area.h
Go to the documentation of this file.
1
12#pragma once
13
14#include "length.h"
15
16namespace SI {
17template <typename _type, typename _ratio>
18using area_t = detail::unit_t<'L', std::ratio<2>, _type, _ratio>;
19
20template <typename _type> using square_metre_t = area_t<_type, std::ratio<1>>;
21template <typename _type>
24
25template <typename _type>
28
29template <typename _type, typename _ratio>
30using volume_t = detail::unit_t<'L', std::ratio<3>, _type, _ratio>;
31
32template <typename _type> using cubic_metre_t = volume_t<_type, std::ratio<1>>;
33template <typename _type>
35template <typename _type>
37
38// specialized unit_symbol for usage with stream operators
39template <>
40struct unit_symbol<'L', std::ratio<1>, std::ratio<2>>
41 : SI::detail::unit_symbol_impl<'m', '2'> {};
42
43template <>
44struct unit_symbol<'L', std::ratio<1, 10000>, std::ratio<2>>
45 : SI::detail::unit_symbol_impl<'c', 'm', '2'> {};
46
47template <>
48struct unit_symbol<'L', std::micro, std::ratio<2>>
49 : SI::detail::unit_symbol_impl<'m', 'm', '2'> {};
50
51template <>
52struct unit_symbol<'L', std::ratio<1>, std::ratio<3>>
53 : SI::detail::unit_symbol_impl<'m', '3'> {};
54
55template <>
56struct unit_symbol<'L', std::ratio<1, 1000000>, std::ratio<3>>
57 : SI::detail::unit_symbol_impl<'c', 'm', '3'> {};
58
59template <>
60struct unit_symbol<'L', std::nano, std::ratio<3>>
61 : SI::detail::unit_symbol_impl<'m', 'm', '3'> {};
62
63inline namespace literals {
64template <char... _digits> constexpr square_metre_t<int64_t> operator""_m2() {
66 SI::detail::parsing::Number<_digits...>::value};
67}
68
69constexpr square_metre_t<long double> operator"" _m2(long double m) {
71}
72
73template <char... _digits>
74constexpr square_centi_metre_t<int64_t> operator""_cm2() {
76 SI::detail::parsing::Number<_digits...>::value};
77}
78
79constexpr square_centi_metre_t<long double> operator"" _cm2(long double cm) {
81}
82
83template <char... _digits>
84constexpr square_milli_metre_t<int64_t> operator""_mm2() {
86 SI::detail::parsing::Number<_digits...>::value};
87}
88
89constexpr square_milli_metre_t<long double> operator"" _mm2(long double mm) {
91}
92
93template <char... _digits> constexpr cubic_metre_t<int64_t> operator""_m3() {
94 return cubic_metre_t<int64_t>{SI::detail::parsing::Number<_digits...>::value};
95}
96
97constexpr cubic_metre_t<long double> operator"" _m3(long double m) {
99}
100
101template <char... _digits>
102constexpr cubic_centi_metre_t<int64_t> operator""_cm3() {
104 SI::detail::parsing::Number<_digits...>::value};
105}
106
107constexpr cubic_centi_metre_t<long double> operator"" _cm3(long double cm) {
109}
110
111template <char... _digits>
112constexpr cubic_milli_metre_t<int64_t> operator""_mm3() {
114 SI::detail::parsing::Number<_digits...>::value};
115}
116
117constexpr cubic_milli_metre_t<long double> operator"" _mm3(long double mm) {
119}
120
121} // namespace literals
122
123} // 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