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

#include <format.h>

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

Public Types

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

Public Member Functions

template<typename ContiguousRange >
void append (const ContiguousRange &range)
 
FMT_CONSTEXPR20 basic_memory_buffer (basic_memory_buffer &&other) noexcept
 
FMT_CONSTEXPR20 basic_memory_buffer (const Allocator &alloc=Allocator())
 
auto get_allocator () const -> Allocator
 
auto operator= (basic_memory_buffer &&other) noexcept -> basic_memory_buffer &
 
void reserve (size_t new_capacity)
 
FMT_CONSTEXPR20 void resize (size_t count)
 
FMT_CONSTEXPR20 ~basic_memory_buffer ()
 
- Public Member Functions inherited from detail::buffer< T >
template<typename U >
void append (const U *begin, const U *end)
 
FMT_INLINE auto begin () const noexcept -> const T *
 
FMT_INLINE auto begin () noexcept -> T *
 
 buffer (const buffer &)=delete
 
constexpr auto capacity () const noexcept -> size_t
 
void clear ()
 
FMT_CONSTEXPR auto data () const noexcept -> const T *
 
FMT_CONSTEXPR auto data () noexcept -> T *
 
FMT_INLINE auto end () const noexcept -> const T *
 
FMT_INLINE auto end () noexcept -> T *
 
void operator= (const buffer &)=delete
 
template<typename Idx >
FMT_CONSTEXPR auto operator[] (Idx index) -> T &
 
template<typename Idx >
FMT_CONSTEXPR auto operator[] (Idx index) const -> const T &
 
FMT_CONSTEXPR20 void push_back (const T &value)
 
constexpr auto size () const noexcept -> size_t
 
FMT_CONSTEXPR20 void try_reserve (size_t new_capacity)
 
FMT_CONSTEXPR20 void try_resize (size_t count)
 

Protected Member Functions

FMT_CONSTEXPR20 void grow (size_t size) override
 
- Protected Member Functions inherited from detail::buffer< T >
 buffer (buffer &&)=default
 
FMT_CONSTEXPR buffer (size_t sz) noexcept
 
FMT_CONSTEXPR20 buffer (T *p=nullptr, size_t sz=0, size_t cap=0) noexcept
 
FMT_CONSTEXPR void set (T *buf_data, size_t buf_capacity) noexcept
 
FMT_CONSTEXPR20 ~buffer ()=default
 

Private Member Functions

FMT_CONSTEXPR20 void deallocate ()
 
FMT_CONSTEXPR20 void move (basic_memory_buffer &other)
 

Private Attributes

FMT_NO_UNIQUE_ADDRESS Allocator alloc_
 
store_ [SIZE]
 

Detailed Description

template<typename T, size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
class basic_memory_buffer< T, SIZE, Allocator >

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

You can use the memory_buffer type alias for char instead.

Example**::

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

Definition at line 883 of file format.h.

Member Typedef Documentation

◆ const_reference

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

Definition at line 922 of file format.h.

◆ value_type

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

Definition at line 921 of file format.h.

Constructor & Destructor Documentation

◆ basic_memory_buffer() [1/2]

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

Definition at line 924 of file format.h.

◆ ~basic_memory_buffer()

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

Definition at line 930 of file format.h.

◆ basic_memory_buffer() [2/2]

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

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

Definition at line 958 of file format.h.

Member Function Documentation

◆ append()

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

Definition at line 988 of file format.h.

◆ deallocate()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
FMT_CONSTEXPR20 void basic_memory_buffer< T, SIZE, Allocator >::deallocate ( )
inlineprivate

Definition at line 891 of file format.h.

◆ get_allocator()

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

Definition at line 975 of file format.h.

◆ grow()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
FMT_CONSTEXPR20 void basic_memory_buffer< T, SIZE, Allocator >::grow ( size_t  capacity)
inlineoverrideprotectedvirtual

Increases the buffer capacity to hold at least capacity elements.

Implements detail::buffer< T >.

Definition at line 897 of file format.h.

◆ move()

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
FMT_CONSTEXPR20 void basic_memory_buffer< T, SIZE, Allocator >::move ( basic_memory_buffer< T, SIZE, Allocator > &  other)
inlineprivate

Definition at line 934 of file format.h.

◆ operator=()

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

\rst Moves the content of the other basic_memory_buffer object to this one. \endrst

Definition at line 967 of file format.h.

◆ 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.

Definition at line 984 of file format.h.

◆ resize()

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

Definition at line 981 of file format.h.

Member Data Documentation

◆ alloc_

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
FMT_NO_UNIQUE_ADDRESS Allocator basic_memory_buffer< T, SIZE, Allocator >::alloc_
private

Definition at line 888 of file format.h.

◆ store_

template<typename T , size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
T basic_memory_buffer< T, SIZE, Allocator >::store_[SIZE]
private

Definition at line 885 of file format.h.


The documentation for this class was generated from the following file:


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:28