Scippy

SoPlex

Sequential object-oriented simPlex

basic_memory_buffer< T, SIZE, Allocator > Class Template Reference

#include <format.h>

Public Types

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

Public Member Functions

 basic_memory_buffer (const Allocator &alloc=Allocator())
 
 ~basic_memory_buffer () FMT_OVERRIDE
 
 basic_memory_buffer (basic_memory_buffer &&other) FMT_NOEXCEPT
 
basic_memory_bufferoperator= (basic_memory_buffer &&other) FMT_NOEXCEPT
 
Allocator get_allocator () const
 
- Public Member Functions inherited from buffer< T >
 buffer (const buffer &)=delete
 
void operator= (const buffer &)=delete
 
virtual ~buffer ()=default
 
T * begin () FMT_NOEXCEPT
 
T * end () FMT_NOEXCEPT
 
std::size_t size () const FMT_NOEXCEPT
 
std::size_t capacity () const FMT_NOEXCEPT
 
T * data () FMT_NOEXCEPT
 
const T * data () const FMT_NOEXCEPT
 
void resize (std::size_t new_size)
 
void clear ()
 
void reserve (std::size_t new_capacity)
 
void push_back (const T &value)
 
template<typename U >
void append (const U *begin, const U *end)
 
T & operator[] (std::size_t index)
 
const T & operator[] (std::size_t index) const
 

Protected Member Functions

void grow (std::size_t size) FMT_OVERRIDE
 
- Protected Member Functions inherited from buffer< T >
 buffer (std::size_t sz) FMT_NOEXCEPT
 
 buffer (T *p=nullptr, std::size_t sz=0, std::size_t cap=0) FMT_NOEXCEPT
 
void set (T *buf_data, std::size_t buf_capacity) FMT_NOEXCEPT
 

Private Member Functions

void deallocate ()
 
void move (basic_memory_buffer &other)
 

Private Attributes

store_ [SIZE]
 

Detailed Description

template<typename T, std::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).

Definition at line 599 of file format.h.

Member Typedef Documentation

◆ const_reference

using const_reference = const T&

Definition at line 614 of file format.h.

◆ value_type

using value_type = T

Definition at line 613 of file format.h.

Constructor & Destructor Documentation

◆ basic_memory_buffer() [1/2]

basic_memory_buffer ( const Allocator &  alloc = Allocator())
explicit

Definition at line 616 of file format.h.

◆ ~basic_memory_buffer()

Definition at line 620 of file format.h.

◆ basic_memory_buffer() [2/2]

basic_memory_buffer ( basic_memory_buffer< T, SIZE, Allocator > &&  other)

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

Definition at line 649 of file format.h.

Member Function Documentation

◆ deallocate()

void deallocate ( )
private

Definition at line 604 of file format.h.

◆ get_allocator()

Allocator get_allocator ( ) const

Definition at line 664 of file format.h.

◆ grow()

void grow ( std::size_t  size)
protectedvirtual

Implements buffer< T >.

Definition at line 668 of file format.h.

◆ move()

void move ( basic_memory_buffer< T, SIZE, Allocator > &  other)
private

Definition at line 624 of file format.h.

◆ operator=()

basic_memory_buffer& operator= ( basic_memory_buffer< T, SIZE, Allocator > &&  other)

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

Definition at line 656 of file format.h.

Member Data Documentation

◆ store_

T store_[SIZE]
private

Definition at line 601 of file format.h.

Referenced by basic_memory_buffer< Char >::move().