diff --git a/include/fmt/core.h b/include/fmt/core.h index 449ed042..19cb05b5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -877,7 +877,7 @@ class buffer_appender : public std::back_insert_iterator> { using base = std::back_insert_iterator>; public: - explicit buffer_appender(buffer& buf) : base(buf) {} + using std::back_insert_iterator>::back_insert_iterator; buffer_appender(base it) : base(it) {} buffer_appender& operator++() { diff --git a/test/format-test.cc b/test/format-test.cc index cdd42db5..6057766c 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -217,6 +217,23 @@ static void check_move_buffer( EXPECT_EQ(alloc, buffer2.get_allocator().get()); } +TEST(BufferAppenderTest, BufferAppenderDefaultConstruct) { + // back_insert_iterator is not default-constructible before C++20, so + // buffer_appender can only be default-constructible when back_insert_iterator + // is. + static_assert( + std::is_default_constructible< + std::back_insert_iterator>>::value == + std::is_default_constructible>::value, + ""); +} + +#ifdef __cpp_lib_ranges +TEST(BufferAppenderTest, BufferAppenderOutputIterator) { + static_assert(std::output_iterator, char>); +} +#endif + TEST(MemoryBufferTest, MoveCtorInlineBuffer) { std::allocator alloc; basic_memory_buffer buffer((std_allocator(&alloc)));