Struct ContiguousStorageView::Allocator¶
Defined in File contiguous_storage_view.hpp
Nested Relationships¶
This struct is a nested type of Template Class ContiguousStorageView.
Struct Documentation¶
-
struct
ripple::ContiguousStorageView
::
Allocator
¶ Allocator for contiguous storage.
This can be used to determine the memory requirement for the storage for different spatial configurations, as well as to offset ContiguousStorage elements within the allocated space.
Public Static Functions
-
constexpr auto
allocation_size
(size_t elements) noexcept -> size_t¶ Determines the number of bytes required to allocate a total of
elements
of the types defined by Ts.- Return
The number of bytes required to allocate the given number of elements.
- Parameters
elements
: The number of elements to allocate.
-
template<size_t
Elements
>
constexpr autoallocation_size
() noexcept -> size_t¶ Determines the number of bytes required to allocate a total of Elements of the types defined by Ts.
This overload of the function can be used to allocate static memory when the number of elements in the space is known at compile time.
- Return
The number of bytes required to allocate the given number of elements.
- Template Parameters
Elements
: The number of elements to allocate.
-
constexpr auto
strided_types
() noexcept -> size_t¶ Gets the number of types which are stored strided.
- Return
The number of types which are stored strided.
-
template<size_t
I
>
constexpr autonum_elements
() noexcept -> size_t¶ Gets the number of elements in the Ith type.
This is always 1 since the data is not strided, it looks like a single element.
- Return
The number of elements in the ith type.
- Template Parameters
I
: The index of the type.
-
template<size_t
I
>
constexpr autoelement_byte_size
() noexcept -> size_t¶ Gets the number of bytes for an element in the Ith type.
This returns the total size since all data is stored contiguously.
- Return
The number of bytes for an element in the Ith type.
- Template Parameters
I
: The index of the type to get the element size of.
-
template<typename
SpaceImpl
, typenameDim
, diff_enable_t<Dim, int> = 0>
autooffset
(const Storage &storage, const MultidimSpace<SpaceImpl> &space, Dim &&dim, int amount) noexcept -> Storage¶ Offsets the storage by the amount specified by
amount
in the dimensiondim
.This returns a new ContiguousStorage, offset to the new indices in the space.
- Return
A new ContiguousStorageView which points to the offset data.
- Parameters
storage
: The storage to offset.space
: The space for which the storage is defined.dim
: The dimension to offset in.
- Template Parameters
SpaceImpl
: The implementation of the spatial interface.Dim
: The type of the dimension.
-
template<typename
SpaceImpl
, typenameDim
>
autoshift
(Storage &storage, const MultidimSpace<SpaceImpl> &space, Dim &&dim, int amount) noexcept -> void¶ Shifts the storage by the amount specified by
amount
in the dimensiondim
.- Note
This is essentially an in-place offset which modifies the
storage
to point to the new location.- Parameters
storage
: The storage to offset.space
: The space for which the storage is defined.dim
: The dimension to offset in.
- Template Parameters
SpaceImpl
: The implementation of the spatial interface.Dim
: The type of the dimension.
-
template<typename
SpaceImpl
>
autocreate
(void *ptr, const MultidimSpace<SpaceImpl> &space) noexcept -> Storage¶ Creates the storage, initializing a ContiguousStorageView instance which has its data pointer pointing to the
ptr
.- Note
The memory space should have a size which is returned by the
allocation_size()
method, otherwise this may index into undefined memory.- Parameters
ptr
: A pointer to the beginning of the memory space.space
: The multidimensional space which defines the domain.
- Template Parameters
SpaceImpl
: The implementation of the spatial interface.
Public Static Attributes
-
constexpr size_t
alignment
= Helper::max_align¶ Returns the alignment required to allocate the storage.
-
constexpr auto