File indexing completed on 2025-01-18 09:57:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include <chrono>
0014 #include <iostream>
0015
0016 #if __cplusplus <= 201703L
0017
0018 namespace std {
0019 namespace chrono {
0020
0021
0022
0023
0024
0025
0026
0027 namespace io {
0028
0029 template <typename T>
0030 inline std::string duration_unit( T ) {
0031 return "";
0032 }
0033
0034
0035 template <>
0036 inline std::string duration_unit( std::chrono::nanoseconds ) {
0037 return "ns";
0038 }
0039
0040 template <>
0041 inline std::string duration_unit( std::chrono::microseconds ) {
0042 return "us";
0043 }
0044
0045 template <>
0046 inline std::string duration_unit( std::chrono::milliseconds ) {
0047 return "ms";
0048 }
0049
0050 template <>
0051 inline std::string duration_unit( std::chrono::seconds ) {
0052 return "s";
0053 }
0054
0055 template <>
0056 inline std::string duration_unit( std::chrono::minutes ) {
0057 return "m";
0058 }
0059
0060 template <>
0061 inline std::string duration_unit( std::chrono::hours ) {
0062 return "h";
0063 }
0064 }
0065
0066
0067 template <class Rep, class Period>
0068 std::ostream& operator<<( std::ostream& os, const duration<Rep, Period>& d ) {
0069 os << d.count() << io::duration_unit( d );
0070 return os;
0071 }
0072 }
0073 }
0074
0075 #endif