Skip to content

Commit

Permalink
Fix handling of types with to_string_view and formatter specialization (
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Mar 18, 2021
1 parent a6408a3 commit 15d6145
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/fmt/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class dynamic_format_arg_store
};

template <typename T>
using stored_type = conditional_t<detail::is_string<T>::value,
using stored_type = conditional_t<detail::is_string<T>::value &&
!has_formatter<T, Context>::value &&
!detail::is_reference_wrapper<T>::value,
std::basic_string<char_type>, T>;

// Storage of basic_format_arg must be contiguous.
Expand Down
2 changes: 2 additions & 0 deletions test/args-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ TEST(ArgsTest, StringsAndRefs) {

struct custom_type {
int i = 0;

friend std::string_view to_string_view(const custom_type&) { return ""; }
};

FMT_BEGIN_NAMESPACE
Expand Down

0 comments on commit 15d6145

Please sign in to comment.