From 5926693086ce4586bc7eeeb2a17c9c219a1bb74d Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Fri, 8 Jul 2022 12:55:58 +0200 Subject: [PATCH] Fix formatting of types with custom addressof operator --- include/fmt/core.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 8bb73c71..678ab328 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -13,6 +13,7 @@ #include // std::strlen #include #include +#include #include #include @@ -1270,7 +1271,7 @@ template class value { template FMT_CONSTEXPR FMT_INLINE value(T& val) { using value_type = remove_cvref_t; - custom.value = const_cast(&val); + custom.value = const_cast(std::addressof(val)); // Get the formatter type through the context to allow different contexts // have different extension points, e.g. `formatter` for `format` and // `printf_formatter` for `printf`.