diff --git a/include/fmt/format.h b/include/fmt/format.h index a0e35f4b..93e4b1e6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -685,6 +685,13 @@ class basic_memory_buffer : public detail::buffer { /** Increases the buffer capacity to *new_capacity*. */ void reserve(size_t new_capacity) { this->try_reserve(new_capacity); } + + // Directly append data into the buffer + using detail::buffer::append; + template + void append(const ContiguousRange& range) { + append(range.data(), range.data() + range.size()); + } }; template diff --git a/test/format-test.cc b/test/format-test.cc index 6e6b6af9..b48fd6be 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -236,7 +236,7 @@ TEST(MemoryBufferTest, MoveCtorInlineBuffer) { std::allocator alloc; basic_memory_buffer buffer((TestAllocator(&alloc))); const char test[] = "test"; - buffer.append(test, test + 4); + buffer.append(string_view(test, 4)); check_move_buffer("test", buffer); // Adding one more character fills the inline buffer, but doesn't cause // dynamic allocation.