|
Stratax 0.2.0
|
Owns contiguous dynamically allocated storage. More...
#include <Buffer.hpp>
Classes | |
| struct | uninitialized_t |
| Tag type selecting allocated storage without element initialization. More... | |
Public Types | |
| using | iterator = T* |
| Mutable iterator over contiguous buffer elements. | |
| using | const_iterator = const T* |
| Const iterator over contiguous buffer elements. | |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| Mutable reverse iterator over contiguous buffer elements. | |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| Const reverse iterator over contiguous buffer elements. | |
Public Member Functions | |
| Buffer () noexcept | |
| Creates an empty buffer. | |
| Buffer (std::size_t size) | |
| Creates a buffer with default-initialized elements. | |
| Buffer (std::size_t size, uninitialized_t uninitialized) | |
| Creates a buffer with allocated but uninitialized storage. | |
| Buffer (std::size_t size, const T &value) | |
| Creates a buffer and fills every element with a value. | |
| Buffer (std::initializer_list< T > list) | |
| Creates a buffer from an initializer list. | |
| Buffer (const Buffer &other) | |
| Creates a copy of another buffer. | |
| Buffer (Buffer &&other) noexcept | |
| Transfers ownership from another buffer. | |
| Buffer & | operator= (const Buffer &other) |
| Replaces this buffer with a copy of another buffer. | |
| Buffer & | operator= (Buffer &&other) noexcept |
| Replaces this buffer by taking ownership from another buffer. | |
| ~Buffer () | |
| Releases the owned storage. | |
| T & | operator[] (std::size_t index) noexcept |
| Returns a mutable element reference without bounds checking. | |
| const T & | operator[] (std::size_t index) const noexcept |
| Returns a const element reference without bounds checking. | |
| T & | front () |
| Returns the first element. | |
| const T & | front () const |
| Returns the first element as a const reference. | |
| T & | back () |
| Returns the last element. | |
| const T & | back () const |
| Returns the last element as a const reference. | |
| T * | data () noexcept |
| Returns the raw data pointer. | |
| const T * | data () const noexcept |
| Returns the raw data pointer as a const pointer. | |
| iterator | begin () noexcept |
| Returns an iterator to the first element. | |
| const_iterator | begin () const noexcept |
| Returns a const iterator to the first element. | |
| const_iterator | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| iterator | end () noexcept |
| Returns an iterator one past the last element. | |
| const_iterator | end () const noexcept |
| Returns a const iterator one past the last element. | |
| const_iterator | cend () const noexcept |
| Returns a const iterator one past the last element. | |
| reverse_iterator | rbegin () noexcept |
| Returns a reverse iterator to the last element. | |
| const_reverse_iterator | rbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| const_reverse_iterator | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| reverse_iterator | rend () noexcept |
| Returns a reverse iterator before the first element. | |
| const_reverse_iterator | rend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| const_reverse_iterator | crend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| std::size_t | size () const noexcept |
| Returns the number of stored elements. | |
| bool | empty () const noexcept |
| Returns whether the buffer contains no elements. | |
| void | fill (const T &value) |
| Fills every element with the same value. | |
| void | swap (Buffer &other) noexcept |
| Swaps the contents of two buffers. | |
Static Public Attributes | |
| static constexpr uninitialized_t | uninitialized {} |
| Tag value selecting allocated storage without element initialization. | |
Owns contiguous dynamically allocated storage.
Buffer is the low-level memory container used by Stratax arrays. It manages allocation, destruction, and flat element access, while higher-level types such as Vector, Matrix, and Tensor handle shape semantics and mathematical operations.
The stored elements are always contiguous in memory, and the buffer follows RAII so ownership is released automatically when the object is destroyed.
| T | Element type. |
| Alignment | Alignment used for allocation, defaulting to 64. |
Definition at line 38 of file Buffer.hpp.
| using stratax::core::Buffer< T, Alignment >::const_iterator = const T* |
Const iterator over contiguous buffer elements.
Definition at line 50 of file Buffer.hpp.
| using stratax::core::Buffer< T, Alignment >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Const reverse iterator over contiguous buffer elements.
Definition at line 56 of file Buffer.hpp.
| using stratax::core::Buffer< T, Alignment >::iterator = T* |
Mutable iterator over contiguous buffer elements.
Definition at line 47 of file Buffer.hpp.
| using stratax::core::Buffer< T, Alignment >::reverse_iterator = std::reverse_iterator<iterator> |
Mutable reverse iterator over contiguous buffer elements.
Definition at line 53 of file Buffer.hpp.
|
inlinenoexcept |
Creates an empty buffer.
The buffer owns no storage and contains zero elements.
Definition at line 63 of file Buffer.hpp.
|
inlineexplicit |
Creates a buffer with default-initialized elements.
The buffer allocates storage for the requested number of elements and default-constructs each one in place.
| size | Number of elements to allocate. |
Definition at line 73 of file Buffer.hpp.
|
inline |
Creates a buffer with allocated but uninitialized storage.
Use this overload when you intend to construct the elements later and want to avoid default initialization work.
| size | Number of elements to allocate. |
| uninitialized | Tag selecting uninitialized storage. |
Definition at line 89 of file Buffer.hpp.
|
inline |
Creates a buffer and fills every element with a value.
Each element is copy-constructed from the supplied value.
| size | Number of elements to allocate. |
| value | Value to copy into each element. |
Definition at line 106 of file Buffer.hpp.
|
inline |
Creates a buffer from an initializer list.
The elements are copied in list order.
| list | Source values to copy into the buffer. |
Definition at line 118 of file Buffer.hpp.
|
inline |
Creates a copy of another buffer.
The new buffer owns its own storage and duplicates the source elements.
| other | Buffer to copy from. |
Definition at line 142 of file Buffer.hpp.
|
inlinenoexcept |
Transfers ownership from another buffer.
The source buffer is left empty after the move.
| other | Buffer to move from. |
Definition at line 172 of file Buffer.hpp.
|
inline |
Releases the owned storage.
Destroying a buffer also destroys any constructed elements before the memory is returned to the allocator.
Definition at line 232 of file Buffer.hpp.
|
inline |
Returns the last element.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 305 of file Buffer.hpp.
|
inline |
Returns the last element as a const reference.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 321 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 365 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
Definition at line 355 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 375 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 405 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 435 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 465 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer as a const pointer.
Definition at line 345 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer.
Definition at line 335 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns whether the buffer contains no elements.
Definition at line 485 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 395 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator one past the last element.
Definition at line 385 of file Buffer.hpp.
|
inline |
Fills every element with the same value.
| value | Value to assign to each element. |
Definition at line 495 of file Buffer.hpp.
|
inline |
Returns the first element.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 273 of file Buffer.hpp.
|
inline |
Returns the first element as a const reference.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 289 of file Buffer.hpp.
|
inlinenoexcept |
Replaces this buffer by taking ownership from another buffer.
The current contents are destroyed before the source storage is adopted.
| other | Buffer to move from. |
Definition at line 209 of file Buffer.hpp.
|
inline |
Replaces this buffer with a copy of another buffer.
This assignment provides the strong exception guarantee by copying into a temporary buffer first.
| other | Buffer to copy from. |
Definition at line 189 of file Buffer.hpp.
|
inlinenoexcept |
Returns a const element reference without bounds checking.
| index | Flat element index. |
Definition at line 261 of file Buffer.hpp.
|
inlinenoexcept |
Returns a mutable element reference without bounds checking.
| index | Flat element index. |
Definition at line 247 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 425 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the last element.
Definition at line 415 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 455 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator before the first element.
Definition at line 445 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns the number of stored elements.
Definition at line 475 of file Buffer.hpp.
|
inlinenoexcept |
Swaps the contents of two buffers.
| other | Buffer to exchange state with. |
Definition at line 505 of file Buffer.hpp.
|
staticconstexpr |
Tag value selecting allocated storage without element initialization.
Definition at line 44 of file Buffer.hpp.