-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathlength_lit.cpp
More file actions
136 lines (111 loc) · 3.49 KB
/
length_lit.cpp
File metadata and controls
136 lines (111 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <cmath>
// Константы преобразования
constexpr double FEET_TO_METERS = 0.3048;
constexpr double INCHES_TO_METERS = 0.0254;
constexpr double METERS_TO_FEET = 1.0 / FEET_TO_METERS;
constexpr double METERS_TO_INCHES = 1.0 / INCHES_TO_METERS;
constexpr double FEET_TO_INCHES = 12.0;
constexpr double INCHES_TO_FEET = 1.0 / FEET_TO_INCHES;
constexpr double METERS_TO_CM = 100.0;
constexpr double CM_TO_METERS = 0.01;
// Футы в другие единицы
constexpr double operator"" _ft_to_m(long double feet)
{
return feet * FEET_TO_METERS;
}
constexpr double operator"" _ft_to_cm(long double feet)
{
return feet * FEET_TO_METERS * METERS_TO_CM;
}
constexpr double operator"" _ft_to_in(long double feet)
{
return feet * FEET_TO_INCHES;
}
// Дюймы в другие единицы
constexpr double operator"" _in_to_m(long double inches)
{
return inches * INCHES_TO_METERS;
}
constexpr double operator"" _in_to_cm(long double inches)
{
return inches * INCHES_TO_METERS * METERS_TO_CM;
}
constexpr double operator"" _in_to_ft(long double inches)
{
return inches * INCHES_TO_FEET;
}
// Метры в другие единицы
constexpr double operator"" _m_to_ft(long double meters)
{
return meters * METERS_TO_FEET;
}
constexpr double operator"" _m_to_in(long double meters)
{
return meters * METERS_TO_INCHES;
}
constexpr double operator"" _m_to_cm(long double meters)
{
return meters * METERS_TO_CM;
}
// Сантиметры в другие единицы
constexpr double operator"" _cm_to_m(long double centimeters)
{
return centimeters * CM_TO_METERS;
}
constexpr double operator"" _cm_to_ft(long double centimeters)
{
return centimeters * CM_TO_METERS * METERS_TO_FEET;
}
constexpr double operator"" _cm_to_in(long double centimeters)
{
return centimeters * CM_TO_METERS * METERS_TO_INCHES;
}
// Перегрузки для целочисленных литералов
constexpr double operator"" _ft_to_m(unsigned long long feet)
{
return static_cast<double>(feet) * FEET_TO_METERS;
}
constexpr double operator"" _ft_to_cm(unsigned long long feet)
{
return static_cast<double>(feet) * FEET_TO_METERS * METERS_TO_CM;
}
constexpr double operator"" _ft_to_in(unsigned long long feet)
{
return static_cast<double>(feet) * FEET_TO_INCHES;
}
constexpr double operator"" _in_to_m(unsigned long long inches)
{
return static_cast<double>(inches) * INCHES_TO_METERS;
}
constexpr double operator"" _in_to_cm(unsigned long long inches)
{
return static_cast<double>(inches) * INCHES_TO_METERS * METERS_TO_CM;
}
constexpr double operator"" _in_to_ft(unsigned long long inches)
{
return static_cast<double>(inches) * INCHES_TO_FEET;
}
constexpr double operator"" _m_to_ft(unsigned long long meters)
{
return static_cast<double>(meters) * METERS_TO_FEET;
}
constexpr double operator"" _m_to_in(unsigned long long meters)
{
return static_cast<double>(meters) * METERS_TO_INCHES;
}
constexpr double operator"" _m_to_cm(unsigned long long meters)
{
return static_cast<double>(meters) * METERS_TO_CM;
}
constexpr double operator"" _cm_to_m(unsigned long long centimeters)
{
return static_cast<double>(centimeters) * CM_TO_METERS;
}
constexpr double operator"" _cm_to_ft(unsigned long long centimeters)
{
return static_cast<double>(centimeters) * CM_TO_METERS * METERS_TO_FEET;
}
constexpr double operator"" _cm_to_in(unsigned long long centimeters)
{
return static_cast<double>(centimeters) * CM_TO_METERS * METERS_TO_INCHES;
}