From 0e89adaa660e98225fd7acbc79935c4c31657c96 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Tue, 22 Dec 2020 23:49:35 +0300 Subject: [PATCH] fix byte formatting with `FMT_COMPILE`, use `__cpp_lib_byte` macro --- include/fmt/format.h | 8 +++++++- test/format-test.cc | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index ceef2ef1..f5835d9d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2112,8 +2112,14 @@ FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { } template ::value && + !std::is_same::value && + !std::is_same::value)> +#else FMT_ENABLE_IF(std::is_enum::value && !std::is_same::value)> +#endif FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { return write( out, static_cast::type>(value)); @@ -3562,7 +3568,7 @@ FMT_FORMAT_AS(Char*, const Char*); FMT_FORMAT_AS(std::basic_string, basic_string_view); FMT_FORMAT_AS(std::nullptr_t, const void*); FMT_FORMAT_AS(detail::std_string_view, basic_string_view); -#if __cplusplus >= 201703L +#ifdef __cpp_lib_byte FMT_FORMAT_AS(std::byte, unsigned); #endif diff --git a/test/format-test.cc b/test/format-test.cc index 81bc406f..e821e773 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1762,7 +1762,7 @@ TEST(FormatTest, JoinArg) { #endif } -#if __cplusplus >= 201703L +#ifdef __cpp_lib_byte TEST(FormatTest, JoinBytes) { std::vector v = {std::byte(1), std::byte(2), std::byte(3)}; EXPECT_EQ("1, 2, 3", fmt::format("{}", fmt::join(v, ", ")));