From 529e25a84d4cb2e5cbfd4af849164403d01f6b31 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Thu, 11 Nov 2021 15:44:48 -0800 Subject: [PATCH] Use SFINAE to stop paths from logging without using u8string --- .../Public/AppInstallerLogging.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/AppInstallerCommonCore/Public/AppInstallerLogging.h b/src/AppInstallerCommonCore/Public/AppInstallerLogging.h index 4a6413c222..4e65c38067 100644 --- a/src/AppInstallerCommonCore/Public/AppInstallerLogging.h +++ b/src/AppInstallerCommonCore/Public/AppInstallerLogging.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #define AICLI_LOG(_channel_,_level_,_outstream_) \ @@ -171,12 +172,6 @@ namespace AppInstaller::Logging { // Force use of the UTF-8 string from a file path. // This should not be necessary when we move to C++20 and convert to using u8string. - friend AppInstaller::Logging::LoggingStream& operator<<(AppInstaller::Logging::LoggingStream& out, std::filesystem::path& path) - { - out.m_out << path.u8string(); - return out; - } - friend AppInstaller::Logging::LoggingStream& operator<<(AppInstaller::Logging::LoggingStream& out, const std::filesystem::path& path) { out.m_out << path.u8string(); @@ -185,7 +180,8 @@ namespace AppInstaller::Logging // Everything else. template - friend AppInstaller::Logging::LoggingStream& operator<<(AppInstaller::Logging::LoggingStream& out, T&& t) + friend std::enable_if_t, std::filesystem::path>, AppInstaller::Logging::LoggingStream&> + operator<<(AppInstaller::Logging::LoggingStream& out, T&& t) { out.m_out << std::forward(t); return out;