mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-14 23:11:05 +00:00
Adding convenience append(range)
This commit is contained in:
parent
0e7cef069b
commit
d0dd678693
@ -685,6 +685,13 @@ class basic_memory_buffer : public detail::buffer<T> {
|
||||
|
||||
/** 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<T>::append;
|
||||
template <typename ContiguousRange>
|
||||
void append(const ContiguousRange& range) {
|
||||
append(range.data(), range.data() + range.size());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, size_t SIZE, typename Allocator>
|
||||
|
@ -236,7 +236,7 @@ TEST(MemoryBufferTest, MoveCtorInlineBuffer) {
|
||||
std::allocator<char> alloc;
|
||||
basic_memory_buffer<char, 5, TestAllocator> 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.
|
||||
|
Loading…
Reference in New Issue
Block a user