From eea97b200061e06918237f77d26e87b9f2899508 Mon Sep 17 00:00:00 2001 From: Marvel Harisson Date: Mon, 19 Oct 2026 11:43:13 +0900 Subject: [PATCH] Write nullptr as a pointer in detail::write detail::write(out, nullptr) picked the const Char* overload, so fmt::to_string(nullptr) and FMT_COMPILE("{}") threw "string pointer is null". Add a nullptr_t overload that forwards to the const void* one. --- include/fmt/format.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/fmt/format.h b/include/fmt/format.h index ebaac1a1..a854cd52 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3913,6 +3913,11 @@ auto write(OutputIt out, const T* value, const format_specs& specs = {}, return write_ptr(out, bit_cast(value), &specs); } +template +auto write(OutputIt out, nullptr_t) -> OutputIt { + return write(out, static_cast(nullptr)); +} + template ::value == type::custom_type &&