Skip to content

Commit

Permalink
use const& for arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexezeder authored and vitaut committed Feb 20, 2021
1 parent 29cc828 commit ab0f7d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ template <typename Char, typename T, int N> struct field {
template <typename OutputIt, typename... Args>
constexpr OutputIt format(OutputIt out, const Args&... args) const {
if constexpr (is_named_arg<typename std::remove_cv<T>::type>::value) {
decltype(T::value) arg = get<N>(args...).value;
const auto& arg = get<N>(args...).value;
return write<Char>(out, arg);
} else {
// This ensures that the argument type is convertile to `const T&`.
Expand Down Expand Up @@ -778,9 +778,9 @@ FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
if constexpr (std::is_same<typename S::char_type, char>::value) {
constexpr basic_string_view<typename S::char_type> str = S();
if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') {
auto first = detail::first(args...);
if constexpr (detail::is_named_arg<typename std::remove_cv<
decltype(first)>::type>::value) {
const auto& first = detail::first(args...);
if constexpr (detail::is_named_arg<
remove_cvref_t<decltype(first)>>::value) {
return fmt::to_string(first.value);
} else {
return fmt::to_string(first);
Expand Down

0 comments on commit ab0f7d7

Please sign in to comment.