From f409fe82c560642a44281b14e2757bc823f8702f Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Fri, 4 Aug 2023 23:57:19 +0500 Subject: [PATCH] Workaround for libc++: std::vector::reference has an overloaded operator& Signed-off-by: Vladislav Shchapov --- include/fmt/core.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/fmt/core.h b/include/fmt/core.h index f6886cf41c664..e0668b7796f7b 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1283,7 +1283,14 @@ template class value { template FMT_CONSTEXPR FMT_INLINE value(T& val) { using value_type = remove_const_t; +#if defined(_LIBCPP_VERSION) + // Workaround for formatter::reference, Char>. + // libc++ std::vector::reference has an overloaded operator&. + // std::addressof is non-constexpr before C++17. + custom.value = const_cast(__builtin_addressof(val)); +#else custom.value = const_cast(&val); +#endif // 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`.