Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
basic_memory_buffer< T, SIZE, Allocator > Class Template Reference
Inheritance diagram for basic_memory_buffer< T, SIZE, Allocator >:
Collaboration diagram for basic_memory_buffer< T, SIZE, Allocator >:

Public Types

using value_type = T
using const_reference = const T&
Public Types inherited from internal::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
basic_memory_buffer & operator= (basic_memory_buffer &&other) FMT_NOEXCEPT
Allocator get_allocator () const
Public Member Functions inherited from internal::buffer< T >
 buffer (const buffer &)=delete
void operator= (const buffer &)=delete
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 internal::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

T 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 >

\rst 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). \endrst

Constructor & Destructor Documentation

◆ basic_memory_buffer() [1/2]

template<typename T, std::size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
basic_memory_buffer< T, SIZE, Allocator >::basic_memory_buffer ( const Allocator & alloc = Allocator())
inlineexplicit
16898 : Allocator(alloc) {
16899 this->set(store_, SIZE);
16900 }
Definition duckdb.cpp:16880
void set(T *buf_data, std::size_t buf_capacity) FMT_NOEXCEPT
Definition duckdb.cpp:15413

◆ ~basic_memory_buffer()

template<typename T, std::size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
basic_memory_buffer< T, SIZE, Allocator >::~basic_memory_buffer ( )
inline
16901{ deallocate(); }

◆ basic_memory_buffer() [2/2]

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

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

16930{ move(other); }

Member Function Documentation

◆ deallocate()

template<typename T, std::size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
void basic_memory_buffer< T, SIZE, Allocator >::deallocate ( )
inlineprivate
16885 {
16886 T* data = this->data();
16887 if (data != store_) Allocator::deallocate(data, this->capacity());
16888 }
std::size_t capacity() const FMT_NOEXCEPT
Definition duckdb.cpp:15436
T * data() FMT_NOEXCEPT
Definition duckdb.cpp:15439

◆ grow()

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

Increases the buffer capacity to hold at least capacity elements.

Implements internal::buffer< T >.

16949 {
16950#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
16951 if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much");
16952#endif
16956 T* old_data = this->data();
16958 // The following code doesn't throw, so the raw pointer above doesn't leak.
16961 this->set(new_data, new_capacity);
16962 // deallocate must not throw according to the standard, but even if it does,
16963 // the buffer already uses the new storage and will deallocate it in
16964 // destructor.
16966}
std::size_t size() const FMT_NOEXCEPT
Definition duckdb.cpp:15433
Here is the call graph for this function:

◆ move()

template<typename T, std::size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
void basic_memory_buffer< T, SIZE, Allocator >::move ( basic_memory_buffer< T, SIZE, Allocator > & other)
inlineprivate
16905 {
16908 T* data = other.data();
16910 if (data == other.store_) {
16911 this->set(store_, capacity);
16912 std::uninitialized_copy(other.store_, other.store_ + size,
16914 } else {
16915 this->set(data, capacity);
16916 // Set pointer to the inline array so that delete is not called
16917 // when deallocating.
16918 other.set(other.store_, 0);
16919 }
16920 this->resize(size);
16921 }
void resize(std::size_t new_size)
Definition duckdb.cpp:15447

◆ operator=()

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

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

16937 {
16938 FMT_ASSERT(this != &other, "");
16939 deallocate();
16940 move(other);
16941 return *this;
16942 }

◆ get_allocator()

template<typename T, std::size_t SIZE = inline_buffer_size, typename Allocator = std::allocator<T>>
Allocator basic_memory_buffer< T, SIZE, Allocator >::get_allocator ( ) const
inline
16945{ return *this; }

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