diff --git a/3party/opening_hours/opening_hours.cpp b/3party/opening_hours/opening_hours.cpp index 1020ca888f..cb9b9466ff 100644 --- a/3party/opening_hours/opening_hours.cpp +++ b/3party/opening_hours/opening_hours.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -96,26 +97,24 @@ class StreamFlagsKeeper std::ios_base::fmtflags m_flags; }; + template -constexpr bool IsChar(TNumber) noexcept -{ - return std::is_same::value || - std::is_same::value || - std::is_same::value; -}; - -template ::type = nullptr> void PrintPaddedNumber(std::ostream & ost, TNumber const number, uint32_t const padding = 1) { - static_assert(std::is_integral::value, "number should be of integral type."); - StreamFlagsKeeper keeper(ost); - ost << std::setw(padding) << std::setfill('0') << number; -} + static constexpr bool isChar = std::is_same_v || + std::is_same_v || + std::is_same_v; -template ::type = nullptr> -void PrintPaddedNumber(std::ostream & ost, TNumber const number, uint32_t const padding = 1) -{ - PrintPaddedNumber(ost, static_cast(number), padding); + if constexpr (isChar) + { + PrintPaddedNumber(ost, static_cast(number), padding); + } + else + { + static_assert(std::is_integral::value, "number should be of integral type."); + StreamFlagsKeeper keeper(ost); + ost << std::setw(padding) << std::setfill('0') << number; + } } void PrintHoursMinutes(std::ostream & ost,