Support printing (const) volatile void* (#4056)

Fixes #4049
This commit is contained in:
Justin Riddell 2024-07-10 16:35:06 +01:00 committed by GitHub
parent 6725225750
commit 13038f37e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -1476,6 +1476,12 @@ template <typename Context> struct arg_mapper {
FMT_MAP_API auto map(void* val) -> const void* { return val; }
FMT_MAP_API auto map(const void* val) -> const void* { return val; }
FMT_MAP_API auto map(volatile void* val) -> const void* {
return const_cast<const void*>(val);
}
FMT_MAP_API auto map(const volatile void* val) -> const void* {
return const_cast<const void*>(val);
}
FMT_MAP_API auto map(std::nullptr_t val) -> const void* { return val; }
// Use SFINAE instead of a const T* parameter to avoid a conflict with the

View File

@ -425,6 +425,14 @@ TEST(arg_test, pointer_arg) {
CHECK_ARG_SIMPLE(cp);
}
TEST(arg_test, volatile_pointer_arg) {
const void* p = nullptr;
volatile int* vip = nullptr;
const volatile int* cvip = nullptr;
CHECK_ARG(char, p, static_cast<volatile void*>(vip));
CHECK_ARG(char, p, static_cast<const volatile void*>(cvip));
}
struct check_custom {
auto operator()(fmt::basic_format_arg<fmt::format_context>::handle h) const
-> test_result {