diff --git a/include/fmt/std.h b/include/fmt/std.h index 4b22eda1..29667b2b 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -98,7 +98,7 @@ FMT_END_NAMESPACE FMT_BEGIN_NAMESPACE template struct formatter, Char, - std::enable_if_t::value>> { + std::enable_if_t::value>> { private: formatter underlying_; static constexpr basic_string_view optional = diff --git a/test/std-test.cc b/test/std-test.cc index f30c514b..39aac5a2 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -12,7 +12,6 @@ #include "fmt/os.h" // fmt::system_category #include "fmt/ranges.h" -#include "fmt/xchar.h" #include "gtest-extra.h" // StartsWith using testing::StartsWith; @@ -53,7 +52,7 @@ TEST(std_test, thread_id) { TEST(std_test, optional) { #ifdef __cpp_lib_optional - EXPECT_EQ(fmt::format(L"{}", std::optional{}), L"none"); + EXPECT_EQ(fmt::format("{}", std::optional{}), "none"); EXPECT_EQ(fmt::format("{}", std::pair{1, "second"}), "(1, \"second\")"); EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2}, std::optional{3}}), diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 1deab2d0..022646da 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -16,6 +16,7 @@ #include "fmt/color.h" #include "fmt/ostream.h" #include "fmt/ranges.h" +#include "fmt/std.h" #include "gtest-extra.h" // Contains #include "util.h" // get_locale @@ -588,4 +589,12 @@ TEST(locale_test, sign) { EXPECT_EQ(fmt::format(std::locale(), L"{:L}", -50), L"-50"); } +TEST(std_test_xchar, optional) { +# ifdef __cpp_lib_optional + EXPECT_EQ(fmt::format(L"{}", std::optional{L'C'}), L"optional(\'C\')"); + EXPECT_EQ(fmt::format(L"{}", std::optional{std::wstring{L"wide string"}}), + L"optional(\"wide string\")"); +# endif +} + #endif // FMT_STATIC_THOUSANDS_SEPARATOR