fmt
Loading...
Searching...
No Matches
fmt::BasicMemoryBuffer< T, SIZE, Allocator > Class Template Referenceexport
module fmt
Inheritance diagram for fmt::BasicMemoryBuffer< T, SIZE, Allocator >:
fmt::detail::Buffer< T >

Public Types

using value_type = T
using const_reference = const T&
Public Types inherited from fmt::detail::Buffer< T >
using value_type = T
using const_reference = const T&

Public Member Functions

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
Public Member Functions inherited from fmt::detail::Buffer< T >
 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 &

Additional Inherited Members

Protected Types inherited from fmt::detail::Buffer< T >
using GrowFun = void (*)(Buffer& buf, size_t capacity)
Protected Member Functions inherited from fmt::detail::Buffer< T >
constexpr Buffer (GrowFun grow, size_t sz) noexcept
constexpr Buffer (GrowFun grow, T *p=nullptr, size_t sz=0, size_t cap=0) noexcept
 Buffer (Buffer &&)=default
constexpr auto set (T *buf_data, size_t buf_capacity) noexcept -> void

Detailed Description

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
Tthe element type.
SIZEthe capacity, kInlineBufferSize by default.
Allocatorthe allocator used once the storage is full.

Example:

auto out = fmt::MemoryBuffer();
fmt::formatTo(std::back_inserter(out), "The answer is {}.", 42);

Constructor & Destructor Documentation

◆ BasicMemoryBuffer()

template<typename T, size_t SIZE = kInlineBufferSize, typename Allocator = detail::Allocator<T>>
fmt::BasicMemoryBuffer< T, SIZE, Allocator >::BasicMemoryBuffer ( BasicMemoryBuffer< T, SIZE, Allocator > && other)
inlineconstexprnoexcept

Constructs a basic_memory_buffer object moving the content of the other object to it.

Member Function Documentation

◆ operator=()

template<typename T, size_t SIZE = kInlineBufferSize, typename Allocator = detail::Allocator<T>>
auto fmt::BasicMemoryBuffer< T, SIZE, Allocator >::operator= ( BasicMemoryBuffer< T, SIZE, Allocator > && other) -> BasicMemoryBuffer &
inlinenoexcept

Moves the content of the other basic_memory_buffer object to this one.

◆ reserve()

template<typename T, size_t SIZE = kInlineBufferSize, typename Allocator = detail::Allocator<T>>
auto fmt::BasicMemoryBuffer< T, SIZE, Allocator >::reserve ( size_t new_capacity) -> void
inline

Increases the buffer capacity to new_capacity.

◆ resize()

template<typename T, size_t SIZE = kInlineBufferSize, typename Allocator = detail::Allocator<T>>
auto fmt::BasicMemoryBuffer< T, SIZE, Allocator >::resize ( size_t count) -> void
inlineconstexpr

Resizes the buffer to contain count elements. If T is a POD type new elements may not be initialized.


The documentation for this class was generated from the following file:
  • /home/mccakit/desktop/mccakit-fmt/fmt/src/fmt/iface/format.cppm