| The Gaudi Framework v32r1 (f65d50dc)

ChronoIO.h
Go to the documentation of this file.
1 #pragma once
2
3 #include <chrono>
4 #include <iostream>
5
6 #if __cplusplus <= 201703L
7
8 namespace std {
9 namespace chrono {
10
17 namespace io {
19 template <typename T>
20 inline std::string duration_unit( T ) {
21 return "";
22 }
23
24 // template specializations for units of time
25 template <>
26 inline std::string duration_unit( std::chrono::nanoseconds ) {
27 return "ns";
28 }
29
30 template <>
31 inline std::string duration_unit( std::chrono::microseconds ) {
32 return "us";
33 }
34
35 template <>
36 inline std::string duration_unit( std::chrono::milliseconds ) {
37 return "ms";
38 }
39
40 template <>
41 inline std::string duration_unit( std::chrono::seconds ) {
42 return "s";
43 }
44
45 template <>
46 inline std::string duration_unit( std::chrono::minutes ) {
47 return "m";
48 }
49
50 template <>
51 inline std::string duration_unit( std::chrono::hours ) {
52 return "h";
53 }
54 } // namespace io
55
57 template <class Rep, class Period>
58 std::ostream& operator<<( std::ostream& os, const duration<Rep, Period>& d ) {
59 os << d.count() << io::duration_unit( d );
60 return os;
61 }
62 } // namespace chrono
63 } // namespace std
64
65 #endif // C++17
std::chrono::nanoseconds
std::chrono::io::duration_unit
std::string duration_unit(T)
Return unit of std::chrono::duration.
Definition: ChronoIO.h:20
std
STL namespace.
std::string
STL class.
std::chrono::duration::count
T count(T... args)
std::chrono::operator<<
std::ostream & operator<<(std::ostream &os, const duration< Rep, Period > &d)
stream operator for std::chrono::duration including unit
Definition: ChronoIO.h:58
std::ostream
STL class.