52 #include <string_view>
62 template<
typename MassDim,
typename LengthDim,
typename TimeDim,
typename AngleDim,
typename CurrentDim,
typename LumDim,
typename SubDim,
typename TempDim>
106 #define QUANTITY_TYPE(_Mdim, _Ldim, _Tdim, _Adim, _CDim, _LumDim, _SubDim, TempDim, name) \
107 typedef RQuantity<std::ratio<_Mdim>, std::ratio<_Ldim>, std::ratio<_Tdim>, std::ratio<_Adim>, std::ratio<_CDim>, std::ratio<_LumDim>, std::ratio<_SubDim>, std::ratio<TempDim>> name;
132 QUANTITY_TYPE(1, -1, -3, 0, 0, 0, 0, 0, QSpectralFluxDensity);
141 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
143 operator+(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
147 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
149 operator-(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
153 template <
typename M1,
typename l1,
typename T1,
typename A1,
typename C1,
typename L1,
typename S1,
typename D1,
154 typename M2,
typename l2,
typename T2,
typename A2,
typename C2,
typename L2,
typename S2,
typename D2>
156 std::ratio_add<T1, T2>, std::ratio_add<A1, A2>,
157 std::ratio_add<C1, C2>, std::ratio_add<L1, L2>,
158 std::ratio_add<S1, S2>, std::ratio_add<D1, D2>
164 std::ratio_add<T1, T2>, std::ratio_add<A1, A2>,
165 std::ratio_add<C1, C2>, std::ratio_add<L1, L2>,
166 std::ratio_add<S1, S2>, std::ratio_add<D1, D2>>
169 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
175 template <
typename M1,
typename l1,
typename T1,
typename A1,
typename C1,
typename L1,
typename S1,
typename D1,
176 typename M2,
typename l2,
typename T2,
typename A2,
typename C2,
typename L2,
typename S2,
typename D2>
178 std::ratio_subtract<T1, T2>, std::ratio_subtract<A1, A2>,
179 std::ratio_subtract<C1, C2>, std::ratio_subtract<L1, L2>,
180 std::ratio_subtract<S1, S2>, std::ratio_subtract<D1, D2>>
181 operator/(
const RQuantity<M1, l1, T1, A1, C1, L1, S1, D1>& lhs,
const RQuantity<M2, l2, T2, A2, C2, L2, S2, D2>& rhs)
184 std::ratio_subtract<T1, T2>, std::ratio_subtract<A1, A2>,
185 std::ratio_subtract<C1, C2>, std::ratio_subtract<L1, L2>,
186 std::ratio_subtract<S1, S2>, std::ratio_subtract<D1, D2>>
189 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
191 std::ratio_subtract<std::ratio<0>, l>,
192 std::ratio_subtract<std::ratio<0>, T>,
193 std::ratio_subtract<std::ratio<0>, A>,
194 std::ratio_subtract<std::ratio<0>, C>,
195 std::ratio_subtract<std::ratio<0>, L>,
196 std::ratio_subtract<std::ratio<0>, S>,
197 std::ratio_subtract<std::ratio<0>, D>>
201 std::ratio_subtract<std::ratio<0>, l>,
202 std::ratio_subtract<std::ratio<0>, T>,
203 std::ratio_subtract<std::ratio<0>, A>,
204 std::ratio_subtract<std::ratio<0>, C>,
205 std::ratio_subtract<std::ratio<0>, L>,
206 std::ratio_subtract<std::ratio<0>, S>,
207 std::ratio_subtract<std::ratio<0>, D>>
210 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
220 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
221 constexpr
bool operator==(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
225 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
226 constexpr
bool operator!=(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
230 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
231 constexpr
bool operator<=(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
235 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
236 constexpr
bool operator>=(
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
240 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
241 constexpr
bool operator< (
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
245 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
246 constexpr
bool operator> (
const RQuantity<M, l, T, A, C, L, S, D>& lhs,
const RQuantity<M, l, T, A, C, L, S, D>& rhs)
256 constexpr QMass
kg(1.0);
265 constexpr QLength
metre(1.0);
301 constexpr QTime
second(1.0);
306 constexpr QFrequency
Hz(1.0);
311 constexpr QForce
newton(1.0);
315 constexpr QPressure
Pascal(1.0);
321 constexpr QCurrent
ampere(1.0);
335 constexpr QLuminosity
candela(1.0);
338 constexpr QSubstance
mole(1.0);
341 constexpr QTemperature
degK(1.0);
368 constexpr QLength
operator"" _pc(
long double x) {
return static_cast<double>(x)*
parsec; }
369 constexpr QLength
operator"" _pc(
unsigned long long int x) {
return static_cast<double>(x)*
parsec; }
375 constexpr QLength
operator"" _AA(
long double x) {
return static_cast<double>(x)*
angstrom; }
376 constexpr QLength
operator"" _nm(
long double x) {
return static_cast<double>(x)*
nanometre; }
377 constexpr QLength
operator"" _mm(
long double x) {
return static_cast<double>(x)*
millimetre; }
378 constexpr QLength
operator"" _cm(
long double x) {
return static_cast<double>(x)*
centimetre; }
379 constexpr QLength
operator"" _m(
long double x) {
return static_cast<double>(x)*
metre; }
380 constexpr QLength
operator"" _km(
long double x) {
return static_cast<double>(x)*
kilometre; }
381 constexpr QLength
operator"" _mi(
long double x) {
return static_cast<double>(x)*
mile; }
382 constexpr QLength
operator"" _yd(
long double x) {
return static_cast<double>(x)*
yard; }
383 constexpr QLength
operator"" _ft(
long double x) {
return static_cast<double>(x)*
foot; }
384 constexpr QLength
operator"" _in(
long double x) {
return static_cast<double>(x)*
inch; }
385 constexpr QLength
operator"" _mm(
unsigned long long int x) {
return static_cast<double>(x)*
millimetre; }
386 constexpr QLength
operator"" _cm(
unsigned long long int x) {
return static_cast<double>(x)*
centimetre; }
387 constexpr QLength
operator"" _m(
unsigned long long int x) {
return static_cast<double>(x)*
metre; }
388 constexpr QLength
operator"" _km(
unsigned long long int x) {
return static_cast<double>(x)*
kilometre; }
389 constexpr QLength
operator"" _mi(
unsigned long long int x) {
return static_cast<double>(x)*
mile; }
390 constexpr QLength
operator"" _yd(
unsigned long long int x) {
return static_cast<double>(x)*
yard; }
391 constexpr QLength
operator"" _ft(
unsigned long long int x) {
return static_cast<double>(x)*
foot; }
392 constexpr QLength
operator"" _in(
unsigned long long int x) {
return static_cast<double>(x)*
inch; }
395 constexpr QSpeed
operator"" _mps(
long double x) {
return QSpeed(x); };
396 constexpr QSpeed
operator"" _miph(
long double x) {
return static_cast<double>(x)*
mile /
hour; };
397 constexpr QSpeed
operator"" _kmph(
long double x) {
return static_cast<double>(x)*
kilometre /
hour; };
398 constexpr QSpeed
operator"" _mps(
unsigned long long int x)
399 {
return QSpeed(
static_cast<long double>(x)); };
400 constexpr QSpeed
operator"" _miph(
unsigned long long int x)
401 {
return static_cast<double>(x)*
mile /
hour; };
402 constexpr QSpeed
operator"" _kmph(
unsigned long long int x)
406 constexpr QFrequency
operator"" _Hz(
long double x) {
return QFrequency(x); };
407 constexpr QFrequency
operator"" _Hz(
unsigned long long int x)
408 {
return QFrequency(
static_cast<long double>(x)); };
411 constexpr QTime
operator"" _s(
long double x) {
return QTime(x); };
412 constexpr QTime
operator"" _min(
long double x) {
return static_cast<double>(x)*
minute; };
413 constexpr QTime
operator"" _h(
long double x) {
return static_cast<double>(x)*
hour; };
414 constexpr QTime
operator"" _day(
long double x) {
return static_cast<double>(x)*
day; };
415 constexpr QTime
operator"" _s(
unsigned long long int x) {
return QTime(
static_cast<double>(x)); };
416 constexpr QTime
operator"" _min(
unsigned long long int x) {
return static_cast<double>(x)*
minute; };
417 constexpr QTime
operator"" _h(
unsigned long long int x) {
return static_cast<double>(x)*
hour; };
418 constexpr QTime
operator"" _day(
unsigned long long int x) {
return static_cast<double>(x)*
day; };
421 constexpr QMass
operator"" _kg(
long double x) {
return QMass(x); };
422 constexpr QMass
operator"" _g(
long double x) {
return static_cast<double>(x)*
gram; };
423 constexpr QMass
operator"" _t(
long double x) {
return static_cast<double>(x)*
tonne; };
424 constexpr QMass
operator"" _oz(
long double x) {
return static_cast<double>(x)*
ounce; };
425 constexpr QMass
operator"" _lb(
long double x) {
return static_cast<double>(x)*
pound; };
426 constexpr QMass
operator"" _st(
long double x) {
return static_cast<double>(x)*
stone; };
427 constexpr QMass
operator"" _kg(
unsigned long long int x) {
return QMass(
static_cast<double>(x)); };
428 constexpr QMass
operator"" _g(
unsigned long long int x) {
return static_cast<double>(x)*
gram; };
429 constexpr QMass
operator"" _t(
unsigned long long int x) {
return static_cast<double>(x)*
tonne; };
430 constexpr QMass
operator"" _oz(
unsigned long long int x) {
return static_cast<double>(x)*
ounce; };
431 constexpr QMass
operator"" _lb(
unsigned long long int x) {
return static_cast<double>(x)*
pound; };
432 constexpr QMass
operator"" _st(
unsigned long long int x) {
return static_cast<double>(x)*
stone; };
435 constexpr QAcceleration
operator"" _mps2(
long double x) {
return QAcceleration(x); };
436 constexpr QAcceleration
operator"" _mps2(
unsigned long long int x)
437 {
return QAcceleration(
static_cast<double>(x)); };
438 constexpr QAcceleration
operator"" _G(
long double x) {
return static_cast<double>(x)*
G; };
439 constexpr QAcceleration
operator"" _G(
unsigned long long int x) {
return static_cast<double>(x)*
G; }
442 constexpr QForce
operator"" _N(
long double x) {
return QForce(x); };
443 constexpr QForce
operator"" _N(
unsigned long long int x) {
return QForce(
static_cast<double>(x)); };
444 constexpr QForce
operator"" _lbf(
long double x) {
return static_cast<double>(x)*
poundforce; };
445 constexpr QForce
operator"" _lbf(
unsigned long long int x) {
return static_cast<double>(x)*
poundforce; };
446 constexpr QForce
operator"" _kp(
long double x) {
return static_cast<double>(x)*
kilopond; };
447 constexpr QForce
operator"" _kp(
unsigned long long int x) {
return static_cast<double>(x)*
kilopond; };
450 constexpr QPressure
operator"" _Pa(
long double x) {
return QPressure(x); };
451 constexpr QPressure
operator"" _Pa(
unsigned long long int x)
452 {
return QPressure(
static_cast<double>(x)); };
453 constexpr QPressure
operator"" _bar(
long double x) {
return static_cast<double>(x)*
bar; };
454 constexpr QPressure
operator"" _bar(
unsigned long long int x) {
return static_cast<double>(x)*
bar; };
455 constexpr QPressure
operator"" _psi(
long double x) {
return static_cast<double>(x)*
psi; };
456 constexpr QPressure
operator"" _psi(
unsigned long long int x) {
return static_cast<double>(x)*
psi; };
461 constexpr
long double operator"" _pi(
long double x)
462 {
return static_cast<double>(x) * 3.1415926535897932384626433832795; }
463 constexpr
long double operator"" _pi(
unsigned long long int x)
464 {
return static_cast<double>(x) * 3.1415926535897932384626433832795; }
467 constexpr Angle
radian(1.0);
474 constexpr Angle
operator"" _rad(
long double x) {
return Angle(x); };
475 constexpr Angle
operator"" _rad(
unsigned long long int x) {
return Angle(
static_cast<double>(x)); };
476 constexpr Angle
operator"" _deg(
long double x) {
return static_cast<double>(x)*
degree; };
477 constexpr Angle
operator"" _deg(
unsigned long long int x) {
return static_cast<double>(x)*
degree; };
478 constexpr Angle
operator"" _arcmin(
long double x) {
return Angle(x); };
479 constexpr Angle
operator"" _arcmin(
unsigned long long int x) {
return Angle(
static_cast<double>(x)); };
480 constexpr Angle
operator"" _arcsecond(
long double x) {
return Angle(x); };
481 constexpr Angle
operator"" _arcsecond(
unsigned long long int x) {
return Angle(
static_cast<double>(x)); };
482 constexpr AngleArea
operator"" _steradian(
long double x) {
return AngleArea(x); };
483 constexpr AngleArea
operator"" _steradian(
unsigned long long int x) {
return AngleArea(
static_cast<double>(x)); };
487 #define ConvertTo(_x, _y) (_x).Convert(1.0_##_y)
493 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
495 std::ratio_divide<l, std::ratio<2>>,
496 std::ratio_divide<T, std::ratio<2>>,
497 std::ratio_divide<A, std::ratio<2>>,
498 std::ratio_divide<C, std::ratio<2>>,
499 std::ratio_divide<L, std::ratio<2>>,
500 std::ratio_divide<S, std::ratio<2>>,
501 std::ratio_divide<D, std::ratio<2>>>
505 std::ratio_divide<l, std::ratio<2>>,
506 std::ratio_divide<T, std::ratio<2>>,
507 std::ratio_divide<A, std::ratio<2>>,
508 std::ratio_divide<C, std::ratio<2>>,
509 std::ratio_divide<L, std::ratio<2>>,
510 std::ratio_divide<S, std::ratio<2>>,
511 std::ratio_divide<D, std::ratio<2>>>
514 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
516 std::ratio_multiply<l, std::ratio<2>>,
517 std::ratio_multiply<T, std::ratio<2>>,
518 std::ratio_multiply<A, std::ratio<2>>,
519 std::ratio_multiply<C, std::ratio<2>>,
520 std::ratio_multiply<L, std::ratio<2>>,
521 std::ratio_multiply<S, std::ratio<2>>,
522 std::ratio_multiply<D, std::ratio<2>>>
526 std::ratio_multiply<l, std::ratio<2>>,
527 std::ratio_multiply<T, std::ratio<2>>,
528 std::ratio_multiply<A, std::ratio<2>>,
529 std::ratio_multiply<C, std::ratio<2>>,
530 std::ratio_multiply<L, std::ratio<2>>,
531 std::ratio_multiply<S, std::ratio<2>>,
532 std::ratio_multiply<D, std::ratio<2>>>
537 inline double sin(
const Angle &num)
539 return sin(num.getValue());
541 inline double cos(
const Angle &num)
543 return cos(num.getValue());
545 inline double tan(
const Angle &num)
547 return tan(num.getValue());
553 template <
typename M,
typename l,
typename T,
typename A,
typename C,
typename L,
typename S,
typename D>
560 os << rhs.getValue();
565 os << rhs.getValue();
569 os << rhs.getValue();
573 os << rhs.getValue();
617 {
"erg/second/centimetre2/angstrom",
flam},
618 {
"erg/second/centimetre**2/angstrom",
flam},
619 {
"erg/second/centimetre^2/angstrom",
flam},