Template Struct VecImpl¶
Defined in File array_traits.hpp
Struct Documentation¶
-
template<typename
T
, typenameSize
, typenameLayout
>
structripple
::
VecImpl
¶ This is an implementation class for a statically sized vector class with a flexible storage layout.
The VecImpl class implements the Array interface for a vector with a fixed type and known compile time size.
The data for the elements is allocated according to the layout, and can be contiguous, owned, or strided.
- Note
This is an implementation class, there are aliases for vectors,
- See
- See
Vec.
- Template Parameters
T
: The type of the data for the vector.Size
: The size of the vector.Layout
: The storage layout of the vector.
- Note
This class should not be used directly, use the Vec aliases.
- Template Parameters
T
: The type of the elements in the vector.Size
: The size of the vector.Layout
: The type of the storage layout for the vector.
Public Functions
-
constexpr
VecImpl
() noexcept¶ Default constructor for the vector.
-
constexpr
VecImpl
(T val) noexcept¶ Sets all elements of the vector to the value
val
.- Parameters
val
: The value to set all elements to.
-
template<typename ...
Values
, variadic_size_enable_t<elements, Values...> = 0>
constexprVecImpl
(Values&&... values) noexcept¶ Constructor to create the vector from a list of values.
- Note
This overload is only enabled when the number of elements in the variadic parameter pack matches the number of elements in the vector.
- Note
The types of the values must be convertible to T.
- Parameters
values
: The values to set the elements to.
- Template Parameters
Values
: The types of the values for setting.
-
constexpr
VecImpl
(Storage storage) noexcept¶ Constructor to set the vector from other
storage
.- Parameters
other
: The other storage to use to set the vector.
-
constexpr
VecImpl
(const VecImpl &other) noexcept¶ Copy constructor to set the vector from another vector.
- Parameters
other
: The other vector to use to initialize this one.
-
constexpr
VecImpl
(VecImpl &&other) noexcept¶ Move constructor to set the vector from another vector.
- Parameters
other
: The other vector to use to initialize this one.
-
template<typename
OtherLayout
>
constexprVecImpl
(const VecImpl<T, Size, OtherLayout> &other) noexcept¶ Copy constructor to set the vector from another vector with a different storage layout.
- Parameters
other
: The other vector to use to initialize this one.
- Template Parameters
OtherLayout
: The layout of the other storage.
-
template<typename
OtherLayout
>
constexprVecImpl
(VecImpl<T, Size, OtherLayout> &&other)¶ Move constructor to set the vector from another vector with a different storage layout.
- Parameters
other
: The other vector to use to initialize this one.
- Template Parameters
OtherLayout
: The layout of the other storage.
-
template<typename
Impl
>
constexprVecImpl
(const Array<Impl> &arr)¶ Constructor to create the vector from an array of the same type and size.
- Parameters
arr
: The array to use to create this one.
- Template Parameters
Impl
: The implementation of the array interface.
-
auto
operator=
(const VecImpl &other) noexcept -> VecImpl&¶ Overload of copy assignment overload to copy the elements from another vector to this vector.
- Return
A references to the modified vector.
- Parameters
other
: The other vector to copy from.
-
auto
operator=
(VecImpl &&other) noexcept -> VecImpl&¶ Overload of move assignment overload to move the elements from another vector to this vector.
- Return
A references to the modified vector.
- Parameters
other
: The other vector to move.
-
template<typename
OtherLayout
>
autooperator=
(const VecImpl<T, Size, OtherLayout> &other) noexcept -> VecImpl&¶ Overload of copy assignment overload to copy the elements from another vector with a different storage layout to this vector.
- Return
A references to the modified vector.
- Parameters
other
: The other vector to copy from.
- Template Parameters
OtherLayout
: The layout of the other vector.
-
template<typename
Impl
>
autooperator=
(const Array<Impl> &arr) noexcept -> VecImpl&¶ Overload of copy assignment overload to copy the elements from an array into this vector.
- Return
A references to the modified vector.
- Parameters
arr
: The array to copy.
- Template Parameters
Impl
: The type of the array implementation.
-
template<typename
OtherLayout
>
autooperator=
(VecImpl<T, Size, OtherLayout> &&other) noexcept -> VecImpl&¶ Overload of move assignment overload to copy the elements from another vector to this vector.
- Return
A references to the modified vector.
- Parameters
other
: The other vector to move.
- Template Parameters
OtherLayout
: The layout of the other vector.
-
constexpr auto
operator[]
(size_t i) const noexcept -> const Value&¶ Gets a constant reference to the element at position i.
- Return
A const reference to the element at position i.
- Parameters
i
: The index of the element to get.
-
constexpr auto
operator[]
(size_t i) noexcept -> Value&¶ Gets a reference to the element at position i.
- Return
A reference to the element at position i.
- Parameters
i
: The index of the element to get.
-
template<typename
Index
>
autocomponent
(Index &&i) noexcept -> Value&¶ Gets a reference to the ith component of the state.
- Return
A reference to the component to get.
- Parameters
i
: The index of the component to get.
-
template<typename
Index
>
autocomponent
(Index &&i) const noexcept -> const Value&¶ Gets a const reference to the ith component of the state.
- Return
A const reference to the component to get.
- Parameters
i
: The index of the component to get.
-
constexpr auto
size
() const noexcept -> size_t¶ Gets the number of elements in the vector.
- Return
The number of elements in the vector.
-
constexpr auto
length_squared
() const noexcept -> Value¶ Gets the squared length of the vector.
- Return
The squared length of the vector.
-
constexpr auto
length
() const noexcept -> Value¶ Gets the length of the vector (L2 norm).
- Return
The length of the vector.
-
constexpr auto
normalize
() noexcept -> void¶ Normalizes the vector.