commit 412408a5a161fe3f5c70f208f5dc58bac6035326
parent b79e4087821c993f83f7c4731bbde7aa25612c73
Author: JohnMcPMS <johnmcp@microsoft.com>
Date: Thu, 11 Nov 2021 17:03:00 -0800
Use SFINAE to stop paths from logging without using u8string (#1697)
Diffstat:
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/AppInstallerCommonCore/Public/AppInstallerLogging.h b/src/AppInstallerCommonCore/Public/AppInstallerLogging.h
@@ -8,6 +8,7 @@
#include <sstream>
#include <string>
#include <string_view>
+#include <type_traits>
#include <vector>
#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 <typename T>
- friend AppInstaller::Logging::LoggingStream& operator<<(AppInstaller::Logging::LoggingStream& out, T&& t)
+ friend std::enable_if_t<!std::is_same_v<std::decay_t<T>, std::filesystem::path>, AppInstaller::Logging::LoggingStream&>
+ operator<<(AppInstaller::Logging::LoggingStream& out, T&& t)
{
out.m_out << std::forward<T>(t);
return out;