99#include < logging.h>
1010#include < util/macros.h>
1111#include < util/time.h>
12+ #include < util/types.h>
1213
1314#include < chrono>
1415#include < string>
@@ -58,14 +59,14 @@ class Timer
5859 return strprintf (" %s: %s" , m_prefix, msg);
5960 }
6061
61- if (std::is_same<TimeType, std::chrono::microseconds>::value) {
62+ if constexpr (std::is_same<TimeType, std::chrono::microseconds>::value) {
6263 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) {
6465 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) {
6667 return strprintf (" %s: %s (%.2fs)" , m_prefix, msg, end_time.count () * 0.000001 );
6768 } else {
68- return " Error: unexpected time type" ;
69+ static_assert (ALWAYS_FALSE<TimeType>, " Error: unexpected time type" ) ;
6970 }
7071 }
7172
@@ -81,7 +82,6 @@ class Timer
8182 // ! Forwarded on to LogPrint if specified - has the effect of only
8283 // ! outputting the timing log when a particular debug= category is specified.
8384 const BCLog::LogFlags m_log_category{};
84-
8585};
8686
8787} // namespace BCLog
0 commit comments