Write nullptr as a pointer in detail::write

detail::write<Char>(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.
This commit is contained in:
Marvel Harisson 2026-10-19 11:43:13 +09:00
parent 6151c964c6
commit eea97b2000

View File

@ -3913,6 +3913,11 @@ auto write(OutputIt out, const T* value, const format_specs& specs = {},
return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs);
}
template <typename Char, typename OutputIt>
auto write(OutputIt out, nullptr_t) -> OutputIt {
return write<Char>(out, static_cast<const void*>(nullptr));
}
template <typename Char, typename OutputIt, typename T,
FMT_ENABLE_IF(mapped_type_constant<T, Char>::value ==
type::custom_type &&