28 template<
class traits_t>
32 using traits_type = traits_t;
33 using size_type =
typename traits_type::size_type;
36 static constexpr size_type nSBOSize = traits_type::nSBOSize;
37 static_assert(nSBOSize >= 32);
40 static constexpr
bool bShrinkToFitWhenSmall = traits_type::bShrinkToFitWhenSmall;
44 static constexpr
bool bPreserveContents = traits_type::bPreserveContents;
46 static constexpr size_type nBufferSize = nSBOSize - 2 *
sizeof(size_type);
47 using buffer_type = std::array<std::byte, nBufferSize>;
62 bool resize(size_type nRequestedSize) noexcept;
69 bool reserve(size_type nRequestedSize) noexcept;
120 bool reallocate_to_big(size_type nNewSize) noexcept;
128 void reallocate_to_small(size_type nNewSize) noexcept;
135 QX_FORCE_INLINE size_type get_new_size(size_type nRequestedSize)
const noexcept;
140 buffer_type buffer = buffer_type();
144 size_type m_nSize = 0;
145 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)