TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fmt::internal::MemoryBuffer< T, SIZE, Allocator > Class Template Reference

#include <format.h>

Public Member Functions

 MemoryBuffer (const Allocator &alloc=Allocator())
 
 ~MemoryBuffer ()
 
Allocator get_allocator () const
 
- Public Member Functions inherited from fmt::Buffer< T >
virtual ~Buffer ()
 
std::size_t size () const
 
std::size_t capacity () const
 
void resize (std::size_t new_size)
 
void reserve (std::size_t capacity)
 
void clear () FMT_NOEXCEPT
 
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)
 
- Protected Member Functions inherited from fmt::Buffer< T >
 Buffer (T *ptr=0, std::size_t capacity=0)
 

Private Member Functions

void deallocate ()
 

Private Attributes

data_ [SIZE]
 

Additional Inherited Members

- Protected Attributes inherited from fmt::Buffer< T >
T * ptr_
 
std::size_t size_
 
std::size_t capacity_
 

Constructor & Destructor Documentation

template<typename T, std::size_t SIZE, typename Allocator = std::allocator<T>>
fmt::internal::MemoryBuffer< T, SIZE, Allocator >::MemoryBuffer ( const Allocator &  alloc = Allocator())
inlineexplicit
675  : Allocator(alloc), Buffer<T>(data_, SIZE) {}
T data_[SIZE]
Definition: format.h:663
template<typename T, std::size_t SIZE, typename Allocator = std::allocator<T>>
fmt::internal::MemoryBuffer< T, SIZE, Allocator >::~MemoryBuffer ( )
inline
676 { deallocate(); }
void deallocate()
Definition: format.h:666

Member Function Documentation

template<typename T, std::size_t SIZE, typename Allocator = std::allocator<T>>
void fmt::internal::MemoryBuffer< T, SIZE, Allocator >::deallocate ( )
inlineprivate
666  {
667  if (this->ptr_ != data_) Allocator::deallocate(this->ptr_, this->capacity_);
668  }
T data_[SIZE]
Definition: format.h:663
T * ptr_
Definition: format.h:586
std::size_t capacity_
Definition: format.h:588
template<typename T, std::size_t SIZE, typename Allocator = std::allocator<T>>
Allocator fmt::internal::MemoryBuffer< T, SIZE, Allocator >::get_allocator ( ) const
inline
712 { return *this; }
template<typename T , std::size_t SIZE, typename Allocator >
void fmt::internal::MemoryBuffer< T, SIZE, Allocator >::grow ( std::size_t  size)
protectedvirtual

Increases the buffer capacity to hold at least size elements updating ptr_ and capacity_.

Implements fmt::Buffer< T >.

716  {
717  std::size_t new_capacity = this->capacity_ + this->capacity_ / 2;
718  if (size > new_capacity)
719  new_capacity = size;
720  T *new_ptr = this->allocate(new_capacity);
721  // The following code doesn't throw, so the raw pointer above doesn't leak.
722  std::uninitialized_copy(this->ptr_, this->ptr_ + this->size_,
723  make_ptr(new_ptr, new_capacity));
724  std::size_t old_capacity = this->capacity_;
725  T *old_ptr = this->ptr_;
726  this->capacity_ = new_capacity;
727  this->ptr_ = new_ptr;
728  // deallocate may throw (at least in principle), but it doesn't matter since
729  // the buffer already uses the new storage and will deallocate it in case
730  // of exception.
731  if (old_ptr != data_)
732  Allocator::deallocate(old_ptr, old_capacity);
733 }
std::size_t size_
Definition: format.h:587
T data_[SIZE]
Definition: format.h:663
T * make_ptr(T *ptr, std::size_t)
Definition: format.h:571
std::size_t size() const
Definition: format.h:605
T * ptr_
Definition: format.h:586
std::size_t capacity_
Definition: format.h:588

+ Here is the call graph for this function:

Member Data Documentation

template<typename T, std::size_t SIZE, typename Allocator = std::allocator<T>>
T fmt::internal::MemoryBuffer< T, SIZE, Allocator >::data_[SIZE]
private

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