From 64a779094f58728cb4d5f63fde64590435678193 Mon Sep 17 00:00:00 2001 From: "David P. Sicilia" Date: Wed, 13 Nov 2019 09:11:19 -0500 Subject: [PATCH] Move has_formatter into the public fmt namespace. This will allow users to do SFINAE-friendly checks for the formattability of a type. Fixes #1369 --- include/fmt/core.h | 4 ++-- test/core-test.cc | 8 ++++---- test/format-test.cc | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 02a389fa..68b022a5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -541,14 +541,14 @@ struct FMT_DEPRECATED convert_to_int : bool_constant::value && std::is_convertible::value> {}; -namespace internal { - // Specifies if T has an enabled formatter specialization. A type can be // formattable even if it doesn't have a formatter e.g. via a conversion. template using has_formatter = std::is_constructible>; +namespace internal { + /** A contiguous memory buffer with an optional growing ability. */ template class buffer { private: diff --git a/test/core-test.cc b/test/core-test.cc index acfd2cd0..9aef6aa9 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -453,11 +453,11 @@ template <> struct formatter { FMT_END_NAMESPACE TEST(CoreTest, HasFormatter) { - using fmt::internal::has_formatter; + using fmt::has_formatter; using context = fmt::format_context; - EXPECT_TRUE((has_formatter::value)); - EXPECT_FALSE((has_formatter::value)); - EXPECT_FALSE((has_formatter::value)); + static_assert(has_formatter::value); + static_assert(!has_formatter::value); + static_assert(!has_formatter::value); } struct convertible_to_int { diff --git a/test/format-test.cc b/test/format-test.cc index 61b893c4..165a1425 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1974,8 +1974,8 @@ enum TestEnum { A }; TEST(FormatTest, Enum) { EXPECT_EQ("0", fmt::format("{}", A)); } TEST(FormatTest, FormatterNotSpecialized) { - EXPECT_FALSE((fmt::internal::has_formatter, - fmt::format_context>::value)); + static_assert(!fmt::has_formatter, + fmt::format_context>::value); } #if FMT_HAS_FEATURE(cxx_strong_enums)