The Gaudi Framework
master (37c0b60a)
ChronoIO.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#pragma once
12
13
#include <chrono>
14
#include <iostream>
15
16
#if __cplusplus <= 201703L
17
18
namespace
std
{
19
namespace
chrono {
20
27
namespace
io {
29
template
<
typename
T>
30
inline
std::string
duration_unit
( T ) {
31
return
""
;
32
}
33
34
// template specializations for units of time
35
template
<>
36
inline
std::string
duration_unit
(
std::chrono::nanoseconds
) {
37
return
"ns"
;
38
}
39
40
template
<>
41
inline
std::string
duration_unit
(
std::chrono::microseconds
) {
42
return
"us"
;
43
}
44
45
template
<>
46
inline
std::string
duration_unit
(
std::chrono::milliseconds
) {
47
return
"ms"
;
48
}
49
50
template
<>
51
inline
std::string
duration_unit
(
std::chrono::seconds
) {
52
return
"s"
;
53
}
54
55
template
<>
56
inline
std::string
duration_unit
(
std::chrono::minutes
) {
57
return
"m"
;
58
}
59
60
template
<>
61
inline
std::string
duration_unit
(
std::chrono::hours
) {
62
return
"h"
;
63
}
64
}
// namespace io
65
67
template
<
class
Rep,
class
Period>
68
std::ostream
&
operator<<
(
std::ostream
& os,
const
duration<Rep, Period>
& d ) {
69
os << d.
count
() <<
io::duration_unit
( d );
70
return
os;
71
}
72
}
// namespace chrono
73
}
// namespace std
74
75
#endif // C++17
std::chrono::io::duration_unit
std::string duration_unit(T)
Return unit of std::chrono::duration.
Definition:
ChronoIO.h:30
std::string
STL class.
std::chrono::nanoseconds
std::ostream
STL class.
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:68
std
STL namespace.
std::chrono::duration::count
T count(T... args)
GaudiKernel
include
Gaudi
Chrono
ChronoIO.h
Generated on Thu Dec 19 2024 15:35:00 for The Gaudi Framework by
1.8.18