From d32fe0f3f6f26365dffab4857261896d3174c32a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 12 Jun 2019 09:19:47 -0700 Subject: [PATCH] Fix hadling of nullptr --- include/fmt/core.h | 1 + test/format-test.cc | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index d5551f83..5e0286bf 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -796,6 +796,7 @@ template struct arg_mapper { FMT_CONSTEXPR const void* map(void* val) { return val; } FMT_CONSTEXPR const void* map(const void* val) { return val; } + FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; } template FMT_CONSTEXPR int map(const T*) { // Formatting of arbitrary pointers is disallowed. If you want to output // a pointer cast it to "void *" or "const void *". In particular, this diff --git a/test/format-test.cc b/test/format-test.cc index 0157b65c..033d92ab 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1576,9 +1576,7 @@ TEST(FormatterTest, FormatPointer) { EXPECT_EQ(format("{}", fmt::ptr(up.get())), format("{}", fmt::ptr(up))); std::shared_ptr sp(new int(1)); EXPECT_EQ(format("{}", fmt::ptr(sp.get())), format("{}", fmt::ptr(sp))); -#if FMT_USE_NULLPTR EXPECT_EQ("0x0", format("{}", nullptr)); -#endif } TEST(FormatterTest, FormatString) {