|
Stratax
Scientific computing containers and operations
|
Owns contiguous dynamically allocated storage. More...
#include <Buffer.hpp>
Classes | |
| struct | uninitialized_t |
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. | |
| T * | begin () noexcept |
| Returns an iterator to the first element. | |
| const T * | begin () const noexcept |
| Returns a const iterator to the first element. | |
| const T * | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| T * | end () noexcept |
| Returns an iterator one past the last element. | |
| const T * | end () const noexcept |
| Returns a const iterator one past the last element. | |
| const T * | cend () const noexcept |
| Returns a const iterator one past the last element. | |
| std::reverse_iterator< T * > | rbegin () noexcept |
| Returns a reverse iterator to the last element. | |
| std::reverse_iterator< const T * > | rbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| std::reverse_iterator< const T * > | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| std::reverse_iterator< T * > | rend () noexcept |
| Returns a reverse iterator before the first element. | |
| std::reverse_iterator< const T * > | rend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| std::reverse_iterator< const T * > | 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 {} |
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.
|
inlinenoexcept |
Creates an empty buffer.
The buffer owns no storage and contains zero elements.
Definition at line 48 of file Buffer.hpp.
Referenced by Buffer(), Buffer(), operator=(), operator=(), and swap().
|
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 58 of file Buffer.hpp.
References size().
|
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 74 of file Buffer.hpp.
References size(), and uninitialized.
|
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 91 of file Buffer.hpp.
References size().
|
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 103 of file Buffer.hpp.
References size().
|
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 127 of file Buffer.hpp.
References Buffer().
|
inlinenoexcept |
Transfers ownership from another buffer.
The source buffer is left empty after the move.
| other | Buffer to move from. |
Definition at line 157 of file Buffer.hpp.
References Buffer().
|
inline |
Releases the owned storage.
Destroying a buffer also destroys any constructed elements before the memory is returned to the allocator.
Definition at line 217 of file Buffer.hpp.
|
inline |
Returns the last element.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 290 of file Buffer.hpp.
References empty().
|
inline |
Returns the last element as a const reference.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 306 of file Buffer.hpp.
References empty().
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 350 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
Definition at line 340 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 360 of file Buffer.hpp.
Referenced by crend().
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 390 of file Buffer.hpp.
Referenced by crbegin().
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 420 of file Buffer.hpp.
References cend().
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 450 of file Buffer.hpp.
References cbegin().
|
inlinenodiscardnoexcept |
Returns the raw data pointer as a const pointer.
Definition at line 330 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer.
Definition at line 320 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 380 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator one past the last element.
Definition at line 370 of file Buffer.hpp.
|
inline |
Fills every element with the same value.
| value | Value to assign to each element. |
Definition at line 480 of file Buffer.hpp.
|
inline |
Returns the first element.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 258 of file Buffer.hpp.
References empty().
|
inline |
Returns the first element as a const reference.
| Exceptions::IndexError | If the buffer is empty. |
Definition at line 274 of file Buffer.hpp.
References empty().
|
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 194 of file Buffer.hpp.
References Buffer().
|
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 174 of file Buffer.hpp.
|
inlinenoexcept |
Returns a const element reference without bounds checking.
| index | Flat element index. |
Definition at line 246 of file Buffer.hpp.
|
inlinenoexcept |
Returns a mutable element reference without bounds checking.
| index | Flat element index. |
Definition at line 232 of file Buffer.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 410 of file Buffer.hpp.
References end().
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the last element.
Definition at line 400 of file Buffer.hpp.
References end().
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 440 of file Buffer.hpp.
References begin().
|
inlinenodiscardnoexcept |
Returns a reverse iterator before the first element.
Definition at line 430 of file Buffer.hpp.
References begin().
|
inlinenodiscardnoexcept |
|
inlinenoexcept |
Swaps the contents of two buffers.
| other | Buffer to exchange state with. |
Definition at line 490 of file Buffer.hpp.
References Buffer().
Referenced by operator=().
|
staticconstexpr |
Definition at line 41 of file Buffer.hpp.
Referenced by Buffer().