Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SFINAE to stop paths from logging without using u8string #1697

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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