From cea9801b3d830355fe6915b9c9262dc59c554122 Mon Sep 17 00:00:00 2001 From: Osyotr Date: Mon, 18 Mar 2024 01:44:13 +0300 Subject: [PATCH] [opening_hours] Replace std::enable_if with if constexpr error C2672: 'PrintPaddedNumber': no matching overloaded function found Signed-off-by: Osyotr --- 3party/opening_hours/opening_hours.cpp | 31 +++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) 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,