9
9
#include < logging.h>
10
10
#include < util/macros.h>
11
11
#include < util/time.h>
12
+ #include < util/types.h>
12
13
13
14
#include < chrono>
14
15
#include < string>
@@ -58,14 +59,14 @@ class Timer
58
59
return strprintf (" %s: %s" , m_prefix, msg);
59
60
}
60
61
61
- if (std::is_same<TimeType, std::chrono::microseconds>::value) {
62
+ if constexpr (std::is_same<TimeType, std::chrono::microseconds>::value) {
62
63
return strprintf (" %s: %s (%iμs)" , m_prefix, msg, end_time.count ());
63
- } else if (std::is_same<TimeType, std::chrono::milliseconds>::value) {
64
+ } else if constexpr (std::is_same<TimeType, std::chrono::milliseconds>::value) {
64
65
return strprintf (" %s: %s (%.2fms)" , m_prefix, msg, end_time.count () * 0.001 );
65
- } else if (std::is_same<TimeType, std::chrono::seconds>::value) {
66
+ } else if constexpr (std::is_same<TimeType, std::chrono::seconds>::value) {
66
67
return strprintf (" %s: %s (%.2fs)" , m_prefix, msg, end_time.count () * 0.000001 );
67
68
} else {
68
- return " Error: unexpected time type" ;
69
+ static_assert (ALWAYS_FALSE<TimeType>, " Error: unexpected time type" ) ;
69
70
}
70
71
}
71
72
@@ -81,7 +82,6 @@ class Timer
81
82
// ! Forwarded on to LogPrint if specified - has the effect of only
82
83
// ! outputting the timing log when a particular debug= category is specified.
83
84
const BCLog::LogFlags m_log_category{};
84
-
85
85
};
86
86
87
87
} // namespace BCLog
0 commit comments