Skip to content

Commit

Permalink
Workaround for libc++: std::vector<bool>::reference has an overloaded…
Browse files Browse the repository at this point in the history
… operator&.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
  • Loading branch information
phprus committed Aug 4, 2023
1 parent 3789f11 commit ad0ca6a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,14 @@ template <typename Context> class value {

template <typename T> FMT_CONSTEXPR FMT_INLINE value(T& val) {
using value_type = remove_const_t<T>;
#if defined(_LIBCPP_VERSION)
// Workaround for formatter<std::vector<bool>::reference, Char>.
// libc++ std::vector<bool>::reference has an overloaded operator&.
// std::addressof is non-constexpr before C++17.
custom.value = const_cast<value_type*>(__builtin_addressof(val));
#else
custom.value = const_cast<value_type*>(&val);
#endif
// Get the formatter type through the context to allow different contexts
// have different extension points, e.g. `formatter<T>` for `format` and
// `printf_formatter<T>` for `printf`.
Expand Down

0 comments on commit ad0ca6a

Please sign in to comment.