Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move has_formatter into the public fmt namespace. #1407

Merged
merged 2 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,14 @@ struct FMT_DEPRECATED convert_to_int
: bool_constant<!std::is_arithmetic<T>::value &&
std::is_convertible<T, int>::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 <typename T, typename Context>
using has_formatter =
std::is_constructible<typename Context::template formatter_type<T>>;

namespace internal {

/** A contiguous memory buffer with an optional growing ability. */
template <typename T> class buffer {
private:
Expand Down
8 changes: 4 additions & 4 deletions test/core-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ template <> struct formatter<enabled_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<enabled_formatter, context>::value));
EXPECT_FALSE((has_formatter<disabled_formatter, context>::value));
EXPECT_FALSE((has_formatter<disabled_formatter_convertible, context>::value));
static_assert(has_formatter<enabled_formatter, context>::value, "");
static_assert(!has_formatter<disabled_formatter, context>::value, "");
static_assert(!has_formatter<disabled_formatter_convertible, context>::value, "");
}

struct convertible_to_int {
Expand Down
4 changes: 2 additions & 2 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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::formatter<TestEnum>,
fmt::format_context>::value));
static_assert(!fmt::has_formatter<fmt::formatter<TestEnum>,
fmt::format_context>::value, "");
}

#if FMT_HAS_FEATURE(cxx_strong_enums)
Expand Down