Skip to content

Commit

Permalink
Use SFINAE to stop paths from logging without using u8string (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcPMS authored Nov 12, 2021
1 parent b79e408 commit 412408a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/AppInstallerCommonCore/Public/AppInstallerLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>

#define AICLI_LOG(_channel_,_level_,_outstream_) \
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit 412408a

Please sign in to comment.