WPILibC++ 2025.3.1
Loading...
Searching...
No Matches
basic_memory_buffer< T, SIZE, Allocator > Class Template Reference

A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE elements stored in the object itself. More...

#include <fmt/format.h>

Inheritance diagram for basic_memory_buffer< T, SIZE, Allocator >:
detail::buffer< T >

Public Types

using value_type = T
 
using const_reference = const T&
 
- Public Types inherited from detail::buffer< T >
using value_type = T
 
using const_reference = const T&
 

Public Member Functions

FMT_CONSTEXPR basic_memory_buffer (const Allocator &alloc=Allocator())
 
FMT_CONSTEXPR20 ~basic_memory_buffer ()
 
FMT_CONSTEXPR20 basic_memory_buffer (basic_memory_buffer &&other) noexcept
 Constructs a basic_memory_buffer object moving the content of the other object to it.
 
auto operator= (basic_memory_buffer &&other) noexcept -> basic_memory_buffer &
 Moves the content of the other basic_memory_buffer object to this one.
 
auto get_allocator () const -> Allocator
 
FMT_CONSTEXPR void resize (size_t count)
 Resizes the buffer to contain count elements.
 
void reserve (size_t new_capacity)
 Increases the buffer capacity to new_capacity.
 
template<typename ContiguousRange >
FMT_CONSTEXPR20 void append (const ContiguousRange &range)
 
- Public Member Functions inherited from detail::buffer< T >
 buffer (const buffer &)=delete
 
void operator= (const buffer &)=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
 Returns the size of this buffer.
 
constexpr auto capacity () const noexcept -> size_t
 Returns the capacity of this buffer.
 
FMT_CONSTEXPR auto data () noexcept -> T *
 Returns a pointer to the buffer data (not null-terminated).
 
FMT_CONSTEXPR auto data () const noexcept -> const T *
 
FMT_CONSTEXPR void clear ()
 Clears this buffer.
 
FMT_CONSTEXPR void try_resize (size_t count)
 
FMT_CONSTEXPR void try_reserve (size_t new_capacity)
 
FMT_CONSTEXPR void push_back (const T &value)
 
template<typename U >
FMT_CONSTEXPR20 void append (const U *begin, const U *end)
 Appends data to the end of the buffer.
 
template<typename Idx >
FMT_CONSTEXPR auto operator[] (Idx index) -> T &
 
template<typename Idx >
FMT_CONSTEXPR auto operator[] (Idx index) const -> const T &
 

Additional Inherited Members

- Protected Member Functions inherited from detail::buffer< T >
FMT_CONSTEXPR buffer (grow_fun grow, size_t sz) noexcept
 
constexpr buffer (grow_fun grow, T *p=nullptr, size_t sz=0, size_t cap=0) noexcept
 
FMT_CONSTEXPR20 ~buffer ()=default
 
 buffer (buffer &&)=default
 
FMT_CONSTEXPR void set (T *buf_data, size_t buf_capacity) noexcept
 Sets the buffer data and capacity.
 

Detailed Description

template<typename T, size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
class basic_memory_buffer< 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 memory_buffer alias for char.

Example:

auto out = fmt::memory_buffer();
fmt::format_to(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).

Member Typedef Documentation

◆ const_reference

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
using basic_memory_buffer< T, SIZE, Allocator >::const_reference = const T&

◆ value_type

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
using basic_memory_buffer< T, SIZE, Allocator >::value_type = T

Constructor & Destructor Documentation

◆ basic_memory_buffer() [1/2]

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
FMT_CONSTEXPR basic_memory_buffer< T, SIZE, Allocator >::basic_memory_buffer ( const Allocator & alloc = Allocator())
inlineexplicit

◆ ~basic_memory_buffer()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
FMT_CONSTEXPR20 basic_memory_buffer< T, SIZE, Allocator >::~basic_memory_buffer ( )
inline

◆ basic_memory_buffer() [2/2]

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
FMT_CONSTEXPR20 basic_memory_buffer< T, SIZE, Allocator >::basic_memory_buffer ( basic_memory_buffer< T, SIZE, Allocator > && other)
inlinenoexcept

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

Member Function Documentation

◆ append()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
template<typename ContiguousRange >
FMT_CONSTEXPR20 void basic_memory_buffer< T, SIZE, Allocator >::append ( const ContiguousRange & range)
inline

◆ get_allocator()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
auto basic_memory_buffer< T, SIZE, Allocator >::get_allocator ( ) const -> Allocator
inline

◆ operator=()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
auto basic_memory_buffer< T, SIZE, Allocator >::operator= ( basic_memory_buffer< T, SIZE, Allocator > && other) -> basic_memory_buffer&
inlinenoexcept

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

◆ reserve()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
void basic_memory_buffer< T, SIZE, Allocator >::reserve ( size_t new_capacity)
inline

Increases the buffer capacity to new_capacity.

◆ resize()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = detail::allocator<T>>
FMT_CONSTEXPR void basic_memory_buffer< T, SIZE, Allocator >::resize ( size_t count)
inline

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: