29 template<
class traits_t>
33 using traits_type = traits_t;
34 using size_type =
typename traits_type::size_type;
37 static constexpr size_type nSBOSize = traits_type::nSBOSize;
38 static_assert(nSBOSize >= 32);
41 static constexpr
bool bShrinkToFitWhenSmall = traits_type::bShrinkToFitWhenSmall;
45 static constexpr
bool bPreserveContents = traits_type::bPreserveContents;
47 static constexpr size_type nBufferSize = nSBOSize - 2 *
sizeof(size_type);
48 using buffer_type = std::array<std::byte, nBufferSize>;
63 bool resize(size_type nRequestedSize) noexcept;
70 bool reserve(size_type nRequestedSize) noexcept;
121 bool reallocate_to_big(size_type nNewSize) noexcept;
129 void reallocate_to_small(size_type nNewSize) noexcept;
136 QX_FORCE_INLINE size_type get_new_size(size_type nRequestedSize)
const noexcept;
141 buffer_type buffer = buffer_type();
145 size_type m_nSize = 0;
146 size_type m_nAllocatedSize = 0;
A type erased small buffer object that works with raw data.
QX_FORCE_INLINE size_type capacity() const noexcept
Get SBO capacity (bytes)
QX_FORCE_INLINE bool is_small() const noexcept
Is the SBO small and fits into the local buffer.
bool reserve(size_type nRequestedSize) noexcept
Make sure the capacity is at least nRequestedSize and allocate memory if needed, but do not change th...
bool shrink_to_fit() noexcept
Reduce capacity to fit the size, possibly moving data to the internal buffer if the size becomes smal...
void free() noexcept
Free allocated memory.
QX_FORCE_INLINE std::byte * data() noexcept
Get SBO data: from a buffer or from a heap.
QX_FORCE_INLINE size_type size() const noexcept
Get SBO size (bytes)
bool resize(size_type nRequestedSize) noexcept
Make sure the capacity is at least nRequestedSize and allocate memory if needed, and change the size ...
#define QX_FORCE_INLINE
Make this function forcefully inlined (except for QX_DEBUG build)