Clementine
Public Types | Public Member Functions | Protected Member Functions | List of all members
basic_memory_buffer< T, SIZE, Allocator > Class Template Referencefinal

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

#include <format.h>

Inheritance diagram for basic_memory_buffer< T, SIZE, Allocator >:
Inheritance graph
[legend]
Collaboration diagram for basic_memory_buffer< T, SIZE, Allocator >:
Collaboration graph
[legend]

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

 basic_memory_buffer (const Allocator &alloc=Allocator())
 
 basic_memory_buffer (basic_memory_buffer &&other) FMT_NOEXCEPT
 Constructs a :class:fmt::basic_memory_buffer object moving the content of the other object to it. More...
 
basic_memory_bufferoperator= (basic_memory_buffer &&other) FMT_NOEXCEPT
 Moves the content of the other basic_memory_buffer object to this one. More...
 
Allocator get_allocator () const
 
void resize (size_t count)
 Resizes the buffer to contain count elements. More...
 
void reserve (size_t new_capacity)
 Increases the buffer capacity to new_capacity. More...
 
template<typename ContiguousRange >
void append (const ContiguousRange &range)
 
- Public Member Functions inherited from detail::buffer< T >
 buffer (const buffer &)=delete
 
void operator= (const buffer &)=delete
 
T * begin () FMT_NOEXCEPT
 
T * end () FMT_NOEXCEPT
 
const T * begin () const FMT_NOEXCEPT
 
const T * end () const FMT_NOEXCEPT
 
size_t size () const FMT_NOEXCEPT
 Returns the size of this buffer. More...
 
size_t capacity () const FMT_NOEXCEPT
 Returns the capacity of this buffer. More...
 
T * data () FMT_NOEXCEPT
 Returns a pointer to the buffer data. More...
 
const T * data () const FMT_NOEXCEPT
 Returns a pointer to the buffer data. More...
 
void clear ()
 Clears this buffer. More...
 
void try_resize (size_t count)
 
void try_reserve (size_t new_capacity)
 
void push_back (const T &value)
 
template<typename U >
void append (const U *begin, const U *end)
 Appends data to the end of the buffer. More...
 
template<typename I >
T & operator[] (I index)
 
template<typename I >
const T & operator[] (I index) const
 

Protected Member Functions

void grow (size_t size) final FMT_OVERRIDE
 Increases the buffer capacity to hold at least capacity elements. More...
 
- Protected Member Functions inherited from detail::buffer< T >
 buffer (size_t sz) FMT_NOEXCEPT
 
 buffer (T *p=nullptr, size_t sz=0, size_t cap=0) FMT_NOEXCEPT
 
void set (T *buf_data, size_t buf_capacity) FMT_NOEXCEPT
 Sets the buffer data and capacity. More...
 

Detailed Description

template<typename T, size_t SIZE = inline_buffer_size, typename Allocator = std::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.

You can use one of the following type aliases for common character types:

+-------------—+---------------------------—+ | Type | Definition | +================+==============================+ | memory_buffer | basic_memory_buffer<char> | +-------------—+---------------------------—+ | wmemory_buffer | basic_memory_buffer<wchar_t> | +-------------—+---------------------------—+

Example**::

fmt::memory_buffer out; format_to(out, "The answer is {}.", 42);

This will append the following output to the out object:

.. code-block:: none

The answer is 42.

The output can be converted to an std::string with to_string(out).

Constructor & Destructor Documentation

◆ basic_memory_buffer()

template<typename T, size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
basic_memory_buffer< T, SIZE, Allocator >::basic_memory_buffer ( basic_memory_buffer< T, SIZE, Allocator > &&  other)
inline

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

Member Function Documentation

◆ grow()

template<typename T , size_t SIZE, typename Allocator >
void basic_memory_buffer< T, SIZE, Allocator >::grow ( size_t  capacity)
finalprotectedvirtual

Increases the buffer capacity to hold at least capacity elements.

Implements detail::buffer< T >.

◆ operator=()

template<typename T, size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
basic_memory_buffer& basic_memory_buffer< T, SIZE, Allocator >::operator= ( basic_memory_buffer< T, SIZE, Allocator > &&  other)
inline

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 = std::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 = std::allocator<T>>
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: