|
| | ResizableBuffer ()=default |
| | Default constructor.
|
| |
| | ResizableBuffer (SizeType minimumSize) noexcept |
| | Constructor that allocates data.
|
| |
| internal constexpr auto | data () noexcept -> Element * |
| | Gets the data.
|
| |
| constexpr auto | data () const noexcept -> const Element * |
| | Gets the data.
|
| |
| constexpr auto | size () const noexcept -> SizeType |
| | Gets the size.
|
| |
| constexpr auto | empty () const noexcept -> bool |
| | Checks if the buffer has size 0.
|
| |
| auto | resize (SizeType minimumSize) -> void |
| | Resizes the buffer.
|
| |
| auto | grow () -> void |
| | Grows the buffer geometrically.
|
| |
template<typename Element,
std::integral SizeType = std::size_t, SizeType kShortDataSize = SizeType(0)>
requires
std::is_trivial_v<Element>
class xentara::utils::memory::ResizableBuffer< Element, SizeType, kShortDataSize >
A buffer that can be resized if buffer space runs out.
This class can be used to call functions that require a preallocated buffer. Such functions often return an error code like ERANGE or ERROR_INSUFFICIENT_BUFFER if the buffer is too small. This class then allows you to resize the buffer and try again.
This class can also optionally use short data optimization by spacifying a shortt data size in the kShortDataSize template parameter.
- Template Parameters
-
| Element | The elements the buffer should hold |
| SizeType | The type to use for the size |
| kShortDataSize | The short data size to use for short data optimization, or 0 to omit short data optimization |