SimulationCraft
SimulationCraft is a tool to explore combat mechanics in the popular MMO RPG World of Warcraft (tm).
buffer< T > Class Template Referenceabstract

A contiguous memory buffer with an optional growing ability. More...

#include <core.h>

Inheritance diagram for buffer< T >:
counting_buffer< T > iterator_buffer< OutputIt, T, Traits > iterator_buffer< T *, T > iterator_buffer< T *, T, fixed_buffer_traits >

Public Types

using value_type = T
 
using const_reference = const T &
 

Public Member Functions

 buffer (const buffer &)=delete
 
void operator= (const buffer &)=delete
 
auto begin () FMT_NOEXCEPT -> T *
 
auto end () FMT_NOEXCEPT -> T *
 
auto begin () const FMT_NOEXCEPT -> const T *
 
auto end () const FMT_NOEXCEPT -> const T *
 
constexpr auto size () const FMT_NOEXCEPT -> size_t
 Returns the size of this buffer. More...
 
constexpr auto capacity () const FMT_NOEXCEPT -> size_t
 Returns the capacity of this buffer. More...
 
FMT_CONSTEXPR auto data () FMT_NOEXCEPT -> T *
 Returns a pointer to the buffer data. More...
 
FMT_CONSTEXPR auto data () const FMT_NOEXCEPT -> const T *
 Returns a pointer to the buffer data. More...
 
void clear ()
 Clears this buffer. More...
 
FMT_CONSTEXPR20 void try_resize (size_t count)
 
FMT_CONSTEXPR20 void try_reserve (size_t new_capacity)
 
FMT_CONSTEXPR20 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 >
FMT_CONSTEXPR auto operator[] (I index) -> T &
 
template<typename I >
FMT_CONSTEXPR auto operator[] (I index) const -> const T &
 

Protected Member Functions

 buffer (size_t sz) FMT_NOEXCEPT
 
FMT_CONSTEXPR20 buffer (T *p=nullptr, size_t sz=0, size_t cap=0) FMT_NOEXCEPT
 
 buffer (buffer &&)=default
 
FMT_CONSTEXPR void set (T *buf_data, size_t buf_capacity) FMT_NOEXCEPT
 Sets the buffer data and capacity. More...
 
virtual FMT_CONSTEXPR20 void grow (size_t capacity)=0
 Increases the buffer capacity to hold at least capacity elements. More...
 

Detailed Description

template<typename T>
class buffer< T >

A contiguous memory buffer with an optional growing ability.

It is an internal class and shouldn't be used directly, only via ~fmtbasic_memory_buffer.

Member Function Documentation

◆ append()

template<typename T>
template<typename U >
template FMT_API void buffer< T >::append ( const U *  begin,
const U *  end 
)

Appends data to the end of the buffer.

◆ capacity()

template<typename T>
constexpr auto buffer< T >::capacity ( ) const -> size_t
inline

Returns the capacity of this buffer.

◆ clear()

template<typename T>
void buffer< T >::clear ( )
inline

Clears this buffer.

◆ data() [1/2]

template<typename T>
FMT_CONSTEXPR auto buffer< T >::data ( ) -> T*
inline

Returns a pointer to the buffer data.

◆ data() [2/2]

template<typename T>
FMT_CONSTEXPR auto buffer< T >::data ( ) const -> const T*
inline

Returns a pointer to the buffer data.

◆ grow()

template<typename T>
virtual FMT_CONSTEXPR20 void buffer< T >::grow ( size_t  capacity)
protectedpure virtual

◆ set()

template<typename T>
FMT_CONSTEXPR void buffer< T >::set ( T *  buf_data,
size_t  buf_capacity 
)
inlineprotected

Sets the buffer data and capacity.

◆ size()

template<typename T>
constexpr auto buffer< T >::size ( ) const -> size_t
inline

Returns the size of this buffer.