Skip to content

Commit

Permalink
Use std::addressof
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
  • Loading branch information
phprus committed Aug 6, 2023
1 parent 67f4479 commit 4f5d184
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cstring> // std::strlen
#include <iterator>
#include <limits>
#include <memory> // std::addressof
#include <string>
#include <type_traits>

Expand Down Expand Up @@ -1281,9 +1282,9 @@ template <typename Context> class value {
FMT_INLINE value(const named_arg_info<char_type>* args, size_t size)
: named_args{args, size} {}

template <typename T> FMT_CONSTEXPR FMT_INLINE value(T& val) {
template <typename T> FMT_CONSTEXPR20 FMT_INLINE value(T& val) {
using value_type = remove_const_t<T>;
custom.value = const_cast<value_type*>(&val);
custom.value = const_cast<value_type*>(std::addressof(val));
// 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 4f5d184

Please sign in to comment.