|
|
constexpr | BasicMemoryBuffer (const Allocator &alloc=Allocator()) |
| constexpr | BasicMemoryBuffer (BasicMemoryBuffer &&other) noexcept |
| auto | operator= (BasicMemoryBuffer &&other) noexcept -> BasicMemoryBuffer & |
|
auto | get_allocator () const -> Allocator |
| constexpr auto | resize (size_t count) -> void |
| auto | reserve (size_t new_capacity) -> void |
|
template<typename ContiguousRange> |
| constexpr auto | append (const ContiguousRange &range) -> void |
|
| Buffer (const Buffer &)=delete |
|
auto | operator= (const Buffer &) -> void=delete |
|
auto | begin () noexcept -> T * |
|
auto | end () noexcept -> T * |
|
auto | begin () const noexcept -> const T * |
|
auto | end () const noexcept -> const T * |
| constexpr auto | size () const noexcept -> size_t |
| constexpr auto | capacity () const noexcept -> size_t |
| constexpr auto | data () noexcept -> T * |
|
constexpr auto | data () const noexcept -> const T * |
| constexpr auto | clear () -> void |
|
constexpr auto | tryResize (size_t count) -> void |
|
constexpr auto | tryReserve (size_t new_capacity) -> void |
|
constexpr auto | push_back (const T &value) -> void |
| template<typename U> |
| constexpr auto | append (const U *begin, const U *end) -> void |
|
template<typename Idx> |
| constexpr auto | operator[] (Idx index) -> T & |
|
template<typename Idx> |
| constexpr auto | operator[] (Idx index) const -> const T & |
template<typename T, size_t SIZE = kInlineBufferSize, typename Allocator = detail::Allocator<T>>
class fmt::BasicMemoryBuffer< T, SIZE, Allocator >
A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE elements stored in the object itself. Most commonly used via the MemoryBuffer alias for char.
Example:
auto out = fmt::MemoryBuffer();
fmt::formatTo(std::back_inserter(out), "The answer is {}.", 42);
This will append "The answer is 42." to out. The buffer content can be converted to std::string with to_string(out). A growable memory buffer with an array of SIZE elements.
Formatting into a buffer avoids the allocation format would make, since output up to SIZE elements needs no heap memory at all.
- Template Parameters
-
| T | the element type. |
| SIZE | the capacity, kInlineBufferSize by default. |
| Allocator | the allocator used once the storage is full. |
Example:
auto out = fmt::MemoryBuffer();
fmt::formatTo(std::back_inserter(out), "The answer is {}.", 42);