From 6b55c83252c95e372bc875f1a8edadc97862284f Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 5 Sep 2021 08:35:08 -0700 Subject: [PATCH] is_const_formattable -> has_const_formatter --- include/fmt/core.h | 12 ++++++------ test/core-test.cc | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index ca751d3a..198691aa 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -684,19 +684,19 @@ class appender; FMT_BEGIN_DETAIL_NAMESPACE template -constexpr auto is_const_formattable_impl(T*) +constexpr auto has_const_formatter_impl(T*) -> decltype(typename Context::template formatter_type().format( std::declval(), std::declval()), true) { return true; } template -constexpr auto is_const_formattable_impl(...) -> bool { +constexpr auto has_const_formatter_impl(...) -> bool { return false; } template -constexpr auto is_const_formattable() -> bool { - return is_const_formattable_impl(static_cast(nullptr)); +constexpr auto has_const_formatter() -> bool { + return has_const_formatter_impl(static_cast(nullptr)); } // Extracts a reference to the container from back_insert_iterator. @@ -1186,7 +1186,7 @@ template class value { auto f = Formatter(); parse_ctx.advance_to(f.parse(parse_ctx)); using qualified_type = - conditional_t(), const T, T>; + conditional_t(), const T, T>; ctx.advance_to(f.format(*static_cast(arg), ctx)); } }; @@ -1335,7 +1335,7 @@ template struct arg_mapper { template > struct formattable - : bool_constant() || + : bool_constant() || !std::is_const>::value || has_fallback_formatter::value> {}; diff --git a/test/core-test.cc b/test/core-test.cc index 4c4fc9da..44acbe37 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -891,11 +891,11 @@ TEST(core_test, adl) { fmt::print(stdout, "{}", s); } -TEST(core_test, is_const_formattable) { - EXPECT_TRUE((fmt::detail::is_const_formattable())); + EXPECT_FALSE((fmt::detail::has_const_formatter())); - EXPECT_FALSE((fmt::detail::is_const_formattable())); } TEST(core_test, format_nonconst) {