From 4f5d18473db21ffca0a02da390c7abe00fe40053 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sat, 5 Aug 2023 22:13:03 +0500 Subject: [PATCH] Use std::addressof Signed-off-by: Vladislav Shchapov --- include/fmt/core.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index f6886cf4..1f3e5801 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -13,6 +13,7 @@ #include // std::strlen #include #include +#include // std::addressof #include #include @@ -1281,9 +1282,9 @@ template class value { FMT_INLINE value(const named_arg_info* args, size_t size) : named_args{args, size} {} - template FMT_CONSTEXPR FMT_INLINE value(T& val) { + template FMT_CONSTEXPR20 FMT_INLINE value(T& val) { using value_type = remove_const_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`.