Skip to content

Commit f337c1f

Browse files
committed
Update main to output generated at 5aba546
1 parent 4d2b3cb commit f337c1f

File tree

15 files changed

+143
-70
lines changed

15 files changed

+143
-70
lines changed

‎include/unit_system.hpp‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
34
#include <algorithm>
45
#include <chrono>
56
#include <cmath>
@@ -11,6 +12,7 @@
1112
#define UNIT_SYSTEM_EXPORT_MACRO
1213
#endif
1314

15+
1416
namespace sakurajin {
1517
namespace unit_system {
1618
// forward declare all units
@@ -45,9 +47,11 @@ namespace sakurajin {
4547
time_si(long double v, long double mult);
4648
time_si(long double v, long double mult, long double off);
4749

50+
4851
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
4952
time_si(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
5053

54+
5155
time_si operator*(long double scalar) const;
5256
void operator*=(long double scalar);
5357

@@ -147,9 +151,11 @@ namespace sakurajin {
147151
length(long double v, long double mult);
148152
length(long double v, long double mult, long double off);
149153

154+
150155
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
151156
length(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
152157

158+
153159
length operator*(long double scalar) const;
154160
void operator*=(long double scalar);
155161

@@ -251,9 +257,11 @@ namespace sakurajin {
251257
mass(long double v, long double mult);
252258
mass(long double v, long double mult, long double off);
253259

260+
254261
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
255262
mass(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
256263

264+
257265
mass operator*(long double scalar) const;
258266
void operator*=(long double scalar);
259267

@@ -345,9 +353,11 @@ namespace sakurajin {
345353
temperature(long double v, long double mult);
346354
temperature(long double v, long double mult, long double off);
347355

356+
348357
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
349358
temperature(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
350359

360+
351361
temperature operator*(long double scalar) const;
352362
void operator*=(long double scalar);
353363

@@ -414,9 +424,11 @@ namespace sakurajin {
414424
amount(long double v, long double mult);
415425
amount(long double v, long double mult, long double off);
416426

427+
417428
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
418429
amount(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
419430

431+
420432
amount operator*(long double scalar) const;
421433
void operator*=(long double scalar);
422434

@@ -483,9 +495,11 @@ namespace sakurajin {
483495
electric_current(long double v, long double mult);
484496
electric_current(long double v, long double mult, long double off);
485497

498+
486499
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
487500
electric_current(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
488501

502+
489503
electric_current operator*(long double scalar) const;
490504
void operator*=(long double scalar);
491505

@@ -586,9 +600,11 @@ namespace sakurajin {
586600
luminous_intensity(long double v, long double mult);
587601
luminous_intensity(long double v, long double mult, long double off);
588602

603+
589604
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
590605
luminous_intensity(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
591606

607+
592608
luminous_intensity operator*(long double scalar) const;
593609
void operator*=(long double scalar);
594610

@@ -656,9 +672,11 @@ namespace sakurajin {
656672
energy(long double v, long double mult);
657673
energy(long double v, long double mult, long double off);
658674

675+
659676
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
660677
energy(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
661678

679+
662680
energy operator*(long double scalar) const;
663681
void operator*=(long double scalar);
664682

@@ -826,9 +844,11 @@ namespace sakurajin {
826844
power(long double v, long double mult);
827845
power(long double v, long double mult, long double off);
828846

847+
829848
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
830849
power(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
831850

851+
832852
power operator*(long double scalar) const;
833853
void operator*=(long double scalar);
834854

@@ -932,9 +952,11 @@ namespace sakurajin {
932952
speed(long double v, long double mult);
933953
speed(long double v, long double mult, long double off);
934954

955+
935956
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
936957
speed(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
937958

959+
938960
speed operator*(long double scalar) const;
939961
void operator*=(long double scalar);
940962

@@ -1011,9 +1033,11 @@ namespace sakurajin {
10111033
acceleration(long double v, long double mult);
10121034
acceleration(long double v, long double mult, long double off);
10131035

1036+
10141037
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
10151038
acceleration(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
10161039

1040+
10171041
acceleration operator*(long double scalar) const;
10181042
void operator*=(long double scalar);
10191043

@@ -1086,9 +1110,11 @@ namespace sakurajin {
10861110
area(long double v, long double mult);
10871111
area(long double v, long double mult, long double off);
10881112

1113+
10891114
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
10901115
area(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
10911116

1117+
10921118
area operator*(long double scalar) const;
10931119
void operator*=(long double scalar);
10941120

@@ -1177,9 +1203,11 @@ namespace sakurajin {
11771203
force(long double v, long double mult);
11781204
force(long double v, long double mult, long double off);
11791205

1206+
11801207
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
11811208
force(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
11821209

1210+
11831211
force operator*(long double scalar) const;
11841212
void operator*=(long double scalar);
11851213

@@ -1285,9 +1313,11 @@ namespace sakurajin {
12851313
momentum(long double v, long double mult);
12861314
momentum(long double v, long double mult, long double off);
12871315

1316+
12881317
template <std::intmax_t numerator, std::intmax_t denumerator = 1>
12891318
momentum(long double v, std::ratio<numerator, denumerator> mult, long double off = 0);
12901319

1320+
12911321
momentum operator*(long double scalar) const;
12921322
void operator*=(long double scalar);
12931323

@@ -1438,6 +1468,7 @@ namespace sakurajin {
14381468
} // namespace unit_system
14391469
} // namespace sakurajin
14401470

1471+
14411472
// add all constants
14421473
namespace sakurajin {
14431474
namespace unit_system {

‎src/acceleration.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "cmath"
12
#include "unit_system.hpp"
23

34
sakurajin::unit_system::acceleration::acceleration()
@@ -155,11 +156,6 @@ sakurajin::unit_system::force sakurajin::unit_system::acceleration::operator*(co
155156
// external functions
156157

157158

158-
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::acceleration& t) {
159-
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
160-
return os << t1.value << " metre per second^2";
161-
}
162-
163159
sakurajin::unit_system::acceleration
164160
sakurajin::unit_system::unit_cast(const sakurajin::unit_system::acceleration& unit, long double new_multiplier, long double new_offset) {
165161
return unit.convert_copy(new_multiplier, new_offset);
@@ -175,11 +171,18 @@ sakurajin::unit_system::acceleration sakurajin::unit_system::clamp(const sakuraj
175171
return sakurajin::unit_system::acceleration{val, unit.multiplier, unit.offset};
176172
}
177173

174+
178175
sakurajin::unit_system::acceleration std::abs(const sakurajin::unit_system::acceleration& unit) {
179176
auto inv = -unit;
180177
return unit > inv ? unit : inv;
181178
}
182179

180+
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::acceleration& t) {
181+
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
182+
return os << t1.value << " metre per second^2";
183+
}
184+
185+
183186
// literals
184187

185188

‎src/amount.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "cmath"
12
#include "unit_system.hpp"
23

34
sakurajin::unit_system::amount::amount()
@@ -139,11 +140,6 @@ void sakurajin::unit_system::amount::operator=(const sakurajin::unit_system::amo
139140
// external functions
140141

141142

142-
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::amount& t) {
143-
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
144-
return os << t1.value << " things";
145-
}
146-
147143
sakurajin::unit_system::amount
148144
sakurajin::unit_system::unit_cast(const sakurajin::unit_system::amount& unit, long double new_multiplier, long double new_offset) {
149145
return unit.convert_copy(new_multiplier, new_offset);
@@ -159,11 +155,18 @@ sakurajin::unit_system::amount sakurajin::unit_system::clamp(const sakurajin::un
159155
return sakurajin::unit_system::amount{val, unit.multiplier, unit.offset};
160156
}
161157

158+
162159
sakurajin::unit_system::amount std::abs(const sakurajin::unit_system::amount& unit) {
163160
auto inv = -unit;
164161
return unit > inv ? unit : inv;
165162
}
166163

164+
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::amount& t) {
165+
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
166+
return os << t1.value << " things";
167+
}
168+
169+
167170
// literals
168171

169172

‎src/area.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "cmath"
12
#include "unit_system.hpp"
23

34
sakurajin::unit_system::area::area()
@@ -156,11 +157,6 @@ sakurajin::unit_system::length sakurajin::unit_system::sqrt(const area& unit) {
156157
}
157158

158159

159-
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::area& t) {
160-
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
161-
return os << t1.value << " metre^2";
162-
}
163-
164160
sakurajin::unit_system::area
165161
sakurajin::unit_system::unit_cast(const sakurajin::unit_system::area& unit, long double new_multiplier, long double new_offset) {
166162
return unit.convert_copy(new_multiplier, new_offset);
@@ -176,11 +172,18 @@ sakurajin::unit_system::area sakurajin::unit_system::clamp(const sakurajin::unit
176172
return sakurajin::unit_system::area{val, unit.multiplier, unit.offset};
177173
}
178174

175+
179176
sakurajin::unit_system::area std::abs(const sakurajin::unit_system::area& unit) {
180177
auto inv = -unit;
181178
return unit > inv ? unit : inv;
182179
}
183180

181+
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::area& t) {
182+
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
183+
return os << t1.value << " metre^2";
184+
}
185+
186+
184187
// literals
185188

186189

‎src/electric_current.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "cmath"
12
#include "unit_system.hpp"
23

34
sakurajin::unit_system::electric_current::electric_current()
@@ -142,11 +143,6 @@ void sakurajin::unit_system::electric_current::operator=(const sakurajin::unit_s
142143
// external functions
143144

144145

145-
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::electric_current& t) {
146-
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
147-
return os << t1.value << " Ampere";
148-
}
149-
150146
sakurajin::unit_system::electric_current sakurajin::unit_system::unit_cast(const sakurajin::unit_system::electric_current& unit,
151147
long double new_multiplier,
152148
long double new_offset) {
@@ -163,11 +159,18 @@ sakurajin::unit_system::electric_current sakurajin::unit_system::clamp(const sak
163159
return sakurajin::unit_system::electric_current{val, unit.multiplier, unit.offset};
164160
}
165161

162+
166163
sakurajin::unit_system::electric_current std::abs(const sakurajin::unit_system::electric_current& unit) {
167164
auto inv = -unit;
168165
return unit > inv ? unit : inv;
169166
}
170167

168+
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::electric_current& t) {
169+
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
170+
return os << t1.value << " Ampere";
171+
}
172+
173+
171174
// literals
172175

173176

‎src/energy.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "cmath"
12
#include "unit_system.hpp"
23

34
sakurajin::unit_system::energy::energy()
@@ -176,11 +177,6 @@ sakurajin::unit_system::momentum sakurajin::unit_system::energy::operator/(const
176177
// external functions
177178

178179

179-
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::energy& t) {
180-
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
181-
return os << t1.value << " Joules";
182-
}
183-
184180
sakurajin::unit_system::energy
185181
sakurajin::unit_system::unit_cast(const sakurajin::unit_system::energy& unit, long double new_multiplier, long double new_offset) {
186182
return unit.convert_copy(new_multiplier, new_offset);
@@ -196,11 +192,18 @@ sakurajin::unit_system::energy sakurajin::unit_system::clamp(const sakurajin::un
196192
return sakurajin::unit_system::energy{val, unit.multiplier, unit.offset};
197193
}
198194

195+
199196
sakurajin::unit_system::energy std::abs(const sakurajin::unit_system::energy& unit) {
200197
auto inv = -unit;
201198
return unit > inv ? unit : inv;
202199
}
203200

201+
std::ostream& sakurajin::unit_system::operator<<(std::ostream& os, const sakurajin::unit_system::energy& t) {
202+
auto t1 = sakurajin::unit_system::unit_cast(t, 1);
203+
return os << t1.value << " Joules";
204+
}
205+
206+
204207
// literals
205208

206209

0 commit comments

Comments
 (0)