LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
spacetime.h
Go to the documentation of this file.
1 
16 #ifndef LARDATAALG_UTILITIES_QUANTITIES_SPACETIME_H
17 #define LARDATAALG_UTILITIES_QUANTITIES_SPACETIME_H
18 
19 // LArSoft libraries
22 
23 // C/C++ standard libraries
24 #include <ratio>
25 #include <string_view>
26 
27 //------------------------------------------------------------------------------
28 namespace util::quantities {
29 
30  namespace units {
31 
32  using namespace std::string_view_literals; // for operator""sv()
33 
34  struct Second : public concepts::UnitBase {
35  static constexpr auto symbol = "s"sv;
36  static constexpr auto name = "second"sv;
37  };
38 
39  struct Meter : public concepts::UnitBase {
40  static constexpr auto symbol = "m"sv;
41  static constexpr auto name = "meter"sv;
42  };
43 
44  } // namespace units
45 
46  // -- BEGIN Time -------------------------------------------------------------
64 
67  template <typename R, typename T = double>
69 
70  //
71  // seconds
72  //
74  template <typename T = double>
76 
78  template <typename T = double>
80 
83 
85  using seconds = second;
86 
87  //
88  // milliseconds
89  //
91  template <typename T = double>
93 
95  template <typename T = double>
97 
100 
103 
104  //
105  // microseconds
106  //
108  template <typename T = double>
110 
112  template <typename T = double>
114 
117 
120 
121  //
122  // nanoseconds
123  //
125  template <typename T = double>
127 
129  template <typename T = double>
131 
134 
137 
138  //
139  // picoseconds
140  //
142  template <typename T = double>
144 
146  template <typename T = double>
148 
151 
154 
172  namespace time_literals {
173 
174  // @{
176  constexpr second operator""_s(long double v)
177  {
178  return second{static_cast<double>(v)};
179  }
180  constexpr second operator""_s(unsigned long long int v)
181  {
182  return second{static_cast<double>(v)};
183  }
184  // @}
185 
186  // @{
188  constexpr millisecond operator""_ms(long double v)
189  {
190  return millisecond{static_cast<double>(v)};
191  }
192  constexpr millisecond operator""_ms(unsigned long long int v)
193  {
194  return millisecond{static_cast<double>(v)};
195  }
196  // @}
197 
198  // @{
200  constexpr microsecond operator""_us(long double v)
201  {
202  return microsecond{static_cast<double>(v)};
203  }
204  constexpr microsecond operator""_us(unsigned long long int v)
205  {
206  return microsecond{static_cast<double>(v)};
207  }
208  // @}
209 
210  // @{
212  constexpr nanosecond operator""_ns(long double v)
213  {
214  return nanosecond{static_cast<double>(v)};
215  }
216  constexpr nanosecond operator""_ns(unsigned long long int v)
217  {
218  return nanosecond{static_cast<double>(v)};
219  }
220  // @}
221 
222  // @{
224  constexpr picosecond operator""_ps(long double v)
225  {
226  return picosecond{static_cast<double>(v)};
227  }
228  constexpr picosecond operator""_ps(unsigned long long int v)
229  {
230  return picosecond{static_cast<double>(v)};
231  }
232  // @}
233 
234  } // time_literals
235 
236  // --- BEGIN Time intervals --------------------------------------------------
237 
238  namespace intervals {
239 
241  template <typename R, typename T = double>
243 
244  //
245  // seconds
246  //
248  template <typename T = double>
250 
253 
254  //
255  // milliseconds
256  //
257 
259  template <typename T = double>
261 
264 
265  //
266  // microseconds
267  //
268 
270  template <typename T = double>
272 
275 
276  //
277  // nanoseconds
278  //
279 
281  template <typename T = double>
283 
286 
287  //
288  // picoseconds
289  //
290 
292  template <typename T = double>
294 
297 
298  } // namespace intervals
299 
300  // --- END Time intervals ----------------------------------------------------
301 
302  // --- BEGIN Time points -----------------------------------------------------
303 
304  namespace points {
305 
307  template <typename R, typename T = double, typename Cat = NoCategory>
309 
310  //
311  // second
312  //
314  template <typename T = double, typename Cat = NoCategory>
316 
319 
320  //
321  // millisecond
322  //
323 
325  template <typename T = double, typename Cat = NoCategory>
327 
330 
331  //
332  // microsecond
333  //
334 
336  template <typename T = double, typename Cat = NoCategory>
338 
341 
342  //
343  // nanosecond
344  //
345 
347  template <typename T = double, typename Cat = NoCategory>
349 
352 
353  //
354  // picosecond
355  //
356 
358  template <typename T = double, typename Cat = NoCategory>
360 
363 
364  } // namespace points
365 
366  // --- END Time points -------------------------------------------------------
367 
369  // -- END Time ---------------------------------------------------------------
370 
371  // -- BEGIN Space ------------------------------------------------------------
389 
392  template <typename R, typename T = double>
394 
395  //
396  // meters
397  //
399  template <typename T = double>
401 
403  template <typename T = double>
405 
407  using meter = meter_as<>;
408 
410  using meters = meter;
411 
412  //
413  // kilometers
414  //
416  template <typename T = double>
418 
420  template <typename T = double>
422 
425 
428 
429  //
430  // centimeters
431  //
433  template <typename T = double>
435 
437  template <typename T = double>
439 
442 
445 
446  //
447  // millimeters
448  //
450  template <typename T = double>
452 
454  template <typename T = double>
456 
459 
462 
463  //
464  // micrometers
465  //
467  template <typename T = double>
469 
471  template <typename T = double>
473 
476 
479 
480  //
481  // nanometers
482  //
484  template <typename T = double>
486 
488  template <typename T = double>
490 
493 
496 
497  //
498  // picometers
499  //
501  template <typename T = double>
503 
505  template <typename T = double>
507 
510 
513 
514  //
515  // femtometers
516  //
518  template <typename T = double>
520 
522  template <typename T = double>
524 
527 
530 
550  namespace space_literals {
551 
552  // @{
554  constexpr meter operator""_m(long double v)
555  {
556  return meter{static_cast<double>(v)};
557  }
558  constexpr meter operator""_m(unsigned long long int v)
559  {
560  return meter{static_cast<double>(v)};
561  }
562  // @}
563 
564  // @{
566  constexpr kilometer operator""_km(long double v)
567  {
568  return kilometer{static_cast<double>(v)};
569  }
570  constexpr kilometer operator""_km(unsigned long long int v)
571  {
572  return kilometer{static_cast<double>(v)};
573  }
574  // @}
575 
576  // @{
578  constexpr centimeter operator""_cm(long double v)
579  {
580  return centimeter{static_cast<double>(v)};
581  }
582  constexpr centimeter operator""_cm(unsigned long long int v)
583  {
584  return centimeter{static_cast<double>(v)};
585  }
586  // @}
587 
588  // @{
590  constexpr millimeter operator""_mm(long double v)
591  {
592  return millimeter{static_cast<double>(v)};
593  }
594  constexpr millimeter operator""_mm(unsigned long long int v)
595  {
596  return millimeter{static_cast<double>(v)};
597  }
598  // @}
599 
600  // @{
602  constexpr micrometer operator""_um(long double v)
603  {
604  return micrometer{static_cast<double>(v)};
605  }
606  constexpr micrometer operator""_um(unsigned long long int v)
607  {
608  return micrometer{static_cast<double>(v)};
609  }
610  // @}
611 
612  // @{
614  constexpr nanometer operator""_nm(long double v)
615  {
616  return nanometer{static_cast<double>(v)};
617  }
618  constexpr nanometer operator""_nm(unsigned long long int v)
619  {
620  return nanometer{static_cast<double>(v)};
621  }
622  // @}
623 
624  // @{
626  constexpr picometer operator""_pm(long double v)
627  {
628  return picometer{static_cast<double>(v)};
629  }
630  constexpr picometer operator""_pm(unsigned long long int v)
631  {
632  return picometer{static_cast<double>(v)};
633  }
634  // @}
635 
636  // @{
638  constexpr femtometer operator""_fm(long double v)
639  {
640  return femtometer{static_cast<double>(v)};
641  }
642  constexpr femtometer operator""_fm(unsigned long long int v)
643  {
644  return femtometer{static_cast<double>(v)};
645  }
646  // @}
647 
648  } // space_literals
649 
650  // --- BEGIN Space intervals -------------------------------------------------
651 
652  namespace intervals {
653 
655  template <typename R, typename T = double>
657 
658  //
659  // meters
660  //
662  template <typename T = double>
664 
667 
668  //
669  // kilometers
670  //
671 
673  template <typename T = double>
675 
678 
679  //
680  // centimeters
681  //
682 
684  template <typename T = double>
686 
689 
690  //
691  // millimeters
692  //
693 
695  template <typename T = double>
697 
700 
701  //
702  // micrometers
703  //
704 
706  template <typename T = double>
708 
711 
712  //
713  // nanometers
714  //
715 
717  template <typename T = double>
719 
722 
723  //
724  // picometers
725  //
726 
728  template <typename T = double>
730 
733 
734  //
735  // femtometers
736  //
737 
739  template <typename T = double>
741 
744 
745  } // namespace intervals
746 
747  // --- END Space intervals ---------------------------------------------------
748 
749  // --- BEGIN Space points ----------------------------------------------------
750 
751  namespace points {
752 
754  template <typename R, typename T = double, typename Cat = NoCategory>
756 
757  //
758  // meter
759  //
761  template <typename T = double, typename Cat = NoCategory>
763 
765  using meter = meter_as<>;
766 
767  //
768  // kilometer
769  //
770 
772  template <typename T = double, typename Cat = NoCategory>
774 
777 
778  //
779  // centimeter
780  //
781 
783  template <typename T = double, typename Cat = NoCategory>
785 
788 
789  //
790  // millimeter
791  //
792 
794  template <typename T = double, typename Cat = NoCategory>
796 
799 
800  //
801  // micrometer
802  //
803 
805  template <typename T = double, typename Cat = NoCategory>
807 
810 
811  //
812  // nanometer
813  //
814 
816  template <typename T = double, typename Cat = NoCategory>
818 
821 
822  //
823  // picometer
824  //
825 
827  template <typename T = double, typename Cat = NoCategory>
829 
832 
833  //
834  // femtometer
835  //
836 
838  template <typename T = double, typename Cat = NoCategory>
840 
843 
844  } // namespace points
845 
846  // --- END Space points -------------------------------------------------------
847 
849  // -- END Space --------------------------------------------------------------
850 
851 } // namespace util::quantities
852 
853 //------------------------------------------------------------------------------
854 
855 #endif // LARDATAALG_UTILITIES_QUANTITIES_SPACETIME_H
picosecond_as<> picosecond
Type of time stored in picoseconds, in double precision.
Definition: spacetime.h:150
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
Definition: spacetime.h:116
millimeter_as<> millimeter
Type of space stored in millimeters, in double precision.
Definition: spacetime.h:458
kilometer_as<> kilometer
Type of space stored in kilometers, in double precision.
Definition: spacetime.h:424
millisecond_as<> millisecond
Type of time stored in milliseconds, in double precision.
Definition: spacetime.h:99
femtometer_as<> femtometer
Type of space stored in femtometers, in double precision.
Definition: spacetime.h:526
Defines point and interval variables based on quantities.
A value measured in the specified unit.
Definition: quantities.h:554
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:106
meter_as<> meter
Type of space stored in meters, in double precision.
Definition: spacetime.h:407
Numeric variable proxies with embedded unit of measurement.
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
Definition: spacetime.h:133
picometer_as<> picometer
Type of space stored in picometers, in double precision.
Definition: spacetime.h:509
micrometer_as<> micrometer
Type of space stored in micrometers, in double precision.
Definition: spacetime.h:475
Types of variables with a unit.
Definition: intervals.h:20
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
nanometer_as<> nanometer
Type of space stored in nanometers, in double precision.
Definition: spacetime.h:492
centimeter_as<> centimeter
Type of space stored in centimeters, in double precision.
Definition: spacetime.h:441