This commit is contained in:
Tom Huntington 2023-02-24 21:06:33 +13:00
parent b890509ec1
commit a406d8c5be
2 changed files with 2 additions and 3 deletions

View File

@ -125,7 +125,7 @@ struct formatter<std::optional<T>, Char,
template <typename FormatContext>
auto format(std::optional<T> const& opt, FormatContext& ctx) const
-> decltype(ctx.out()) {
if (not opt) return detail::write<Char>(ctx.out(), none);
if (!opt) return detail::write<Char>(ctx.out(), none);
auto out = ctx.out();
out = detail::write<Char>(out, optional);

View File

@ -59,8 +59,7 @@ TEST(std_test, optional) {
std::optional{3}}),
"[optional(1), optional(2), optional(3)]");
EXPECT_EQ(
fmt::format("{}", std::optional<std::optional<const char*>>{std::optional{
"nested"}}),
fmt::format("{}", std::optional<std::optional<const char*>>{{"nested"}}),
"optional(optional(\"nested\"))");
EXPECT_EQ(
fmt::format("{:<{}}", std::optional{std::string{"left aligned"}}, 30),