diff --git a/include/fmt/compile.h b/include/fmt/compile.h index f10ba4d0..08566a4d 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -455,7 +455,7 @@ template struct field { template constexpr OutputIt format(OutputIt out, const Args&... args) const { if constexpr (is_named_arg::type>::value) { - decltype(T::value) arg = get(args...).value; + const auto& arg = get(args...).value; return write(out, arg); } else { // This ensures that the argument type is convertile to `const T&`. @@ -778,9 +778,9 @@ FMT_INLINE std::basic_string format(const S&, if constexpr (std::is_same::value) { constexpr basic_string_view str = S(); if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') { - auto first = detail::first(args...); - if constexpr (detail::is_named_arg::type>::value) { + const auto& first = detail::first(args...); + if constexpr (detail::is_named_arg< + remove_cvref_t>::value) { return fmt::to_string(first.value); } else { return fmt::to_string(first);