From ee5e35791e75bed6b7c2c3ebd77285a490a59746 Mon Sep 17 00:00:00 2001 From: hhggit Date: Tue, 18 Sep 2018 10:30:06 +0800 Subject: [PATCH] prevent ""fmt/range.h"" from specializing fmt::basic_string_view (#865) --- include/fmt/ranges.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index df22f389..0354ae6d 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -117,6 +117,13 @@ class is_tuple_like_ { !std::is_void(FMT_NULL))>::value; }; +template +struct is_fmt_str_view : std::false_type {}; + +template +struct is_fmt_str_view> : std::true_type { +}; + // Check for integer_sequence #if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900 template @@ -168,6 +175,7 @@ void for_each(Tuple &&tup, F &&f) { template FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&, typename std::enable_if< + !is_fmt_str_view::type>::value && !is_like_std_string::type>::value>::type* = nullptr) { return add_space ? " {}" : "{}"; } @@ -175,6 +183,7 @@ FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&, template FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&, typename std::enable_if< + is_fmt_str_view::type>::value || is_like_std_string::type>::value>::type* = nullptr) { return add_space ? " \"{}\"" : "\"{}\""; } @@ -255,7 +264,8 @@ public: template struct is_range { static FMT_CONSTEXPR_DECL const bool value = - internal::is_range_::value && !internal::is_like_std_string::value; + internal::is_range_::value && !internal::is_like_std_string::value + && !internal::is_fmt_str_view::value; }; template