From aff640c32f9ada045e4f8c289119fb104e5c4290 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Mon, 29 Jul 2024 21:18:20 +0500 Subject: [PATCH] Make fmt::appender implement std::output_iterator concept (#4093) Signed-off-by: Vladislav Shchapov --- include/fmt/format.h | 1 + test/base-test.cc | 8 +------- test/format-test.cc | 7 +++++++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 1ad0d7ac8b3a..708c9051334e 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -110,6 +110,7 @@ namespace std { template <> struct iterator_traits { using iterator_category = output_iterator_tag; using value_type = char; + using difference_type = ptrdiff_t; }; } // namespace std diff --git a/test/base-test.cc b/test/base-test.cc index e03c5d9180bf..4afd99dab39e 100644 --- a/test/base-test.cc +++ b/test/base-test.cc @@ -93,7 +93,7 @@ TEST(string_view_test, compare) { } TEST(base_test, is_locking) { - EXPECT_FALSE(fmt::detail::is_locking()); + EXPECT_FALSE(fmt::detail::is_locking()); } TEST(base_test, is_output_iterator) { @@ -116,12 +116,6 @@ TEST(base_test, is_back_insert_iterator) { std::front_insert_iterator>::value); } -TEST(base_test, buffer_appender) { -#ifdef __cpp_lib_ranges - EXPECT_TRUE((std::output_iterator)); -#endif -} - #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 470 TEST(buffer_test, noncopyable) { EXPECT_FALSE(std::is_copy_constructible>::value); diff --git a/test/format-test.cc b/test/format-test.cc index 86c709816346..62d082a76c0c 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -26,6 +26,9 @@ #include // std::string #include // std::thread #include // std::is_default_constructible +#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE() +# include +#endif #include "gtest-extra.h" #include "mock-allocator.h" @@ -42,6 +45,10 @@ using fmt::detail::uint128_fallback; using testing::Return; using testing::StrictMock; +#ifdef __cpp_lib_concepts +static_assert(std::output_iterator); +#endif + enum { buffer_size = 256 }; TEST(uint128_test, ctor) {