Template Struct Array¶
Defined in File array.hpp
Struct Documentation¶
-
template<typename
Impl
>
structripple
::
Array
¶ The Array class defines a static interface for array type classes.
The Array class defines a static interface for array types essentially types which have contiguous storage and can be accessed with the index operator.
The implementation is provided by the template type Impl, and any derived types which don’t define the necessary functions will fail at compile time when the requried function is called.
The implementation is provided by the template type Impl.
- Template Parameters
Impl
: The implementation of the array interface.
- Template Parameters
Impl
: The implementation of the array interface.
Public Functions
-
constexpr decltype(auto)
operator[]
(size_t i) noexcept¶ Gets the value at position
i
in the array.- Note
This may return a reference or a value, depending on the implementation.
- Return
The element at position i in the array.
- Parameters
i
: The index of the element to return.
-
constexpr decltype(auto)
operator[]
(size_t i) const noexcept¶ Gets the value at position
i
in the array.- Note
This may return a reference or a value, depending on the implementation.
- Parameters
i
: The index of the element to return.
-
constexpr auto
size
() const noexcept -> size_t¶ Gets the number of elements in the array.
- Return
The number of elements in the array.
-
template<typename
ImplOther
>
constexpr autooperator==
(const Array<ImplOther> &other) noexcept -> bool¶ Overload of equality operator to compare one array to another.
- Return
true if all elements of both arrays are the same, false otherwise.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator==
(T val) const noexcept -> bool¶ Overload of equality operator to compare all elements of the array to the given value.
- Note
This overload is only enabled if the type T is comparible to the type stored in the array.
- Return
true if all array elements are equal to the value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator!=
(const Array<ImplOther> &other) noexcept -> bool¶ Overload of inequality operator to compare one array not equal to another.
- Return
true if any element of the arrays are not equal, false otherwise.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator!=
(T val) const noexcept -> bool¶ Overload of inequality operator to compare if any elements of the array are not equal to the given value.
- Return
true if any elements of the array are not equal to the value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator<=
(const Array<ImplOther> &other) noexcept -> bool¶ Overload of less than or equal operator to compare one array to another.
- Return
true if all elements of this array are <= to the corresponding elements in the other array.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator<=
(T val) const noexcept -> bool¶ Overload of comparison operator to compare if all elements of the array are <= the given value.
- Return
true if all elements are less than or equal to the given value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator>=
(const Array<ImplOther> &other) noexcept -> bool¶ Overload of greater than or equal operator to compare one array to another.
- Return
true if all elements of this array are >= the corresponding elements in the other array.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator>=
(T val) const noexcept -> bool¶ Overload of greater than or equal operator to compare if all elements of the array are greater than or equal to the given value.
- Return
true if all elements are greater than or equal to the given value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator<
(const Array<ImplOther> &other) const noexcept -> bool¶ Overload of less than operator to compare one array to another.
- Return
true if all elements of this array are less than the other array elements.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator<
(T val) const noexcept -> bool¶ Overload of less than operator to compare the array elements againt the given value.
- Return
true if all array elements are less than the given value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator>
(const Array<ImplOther> &a) const noexcept -> bool¶ Overload of greater than operator to compare one array to another.
- Return
true if all elements of this array are greater than the elements in the other array.
- Parameters
other
: The other array to compare against this one.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator>
(T val) const noexcept -> bool¶ Overload of greater than operator to compare the elements of the array to given value.
- Return
true if all elements in the array are greater than the given value.
- Parameters
val
: The value to compare to.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator+=
(const Array<ImplOther> &other) noexcept -> Impl&¶ Overload of operator+= to add each element of the other array to this array.
- Note
If the sizes of the arrays are different, this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
other
: The array to add with.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator+=
(T val) noexcept -> Impl&¶ Overload of operator+= to add the value to each element of this array.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
val
: The value to add to each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
, typenameR
= array_impl_t<Impl, ImplOther>>
constexpr autooperator+
(const Array<ImplOther> &other) const noexcept -> R¶ Overload of operator+ to add each element of the other array to this array.
- Return
A new array with either this implementation type, or the implemenation type of the other array, or the fallback type.
- Parameters
other
: The array for the addition.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, typenameR
= array_impl_t<Impl, Impl>, array_value_enable_t<T, Impl> = 0>
constexpr autooperator+
(T val) const noexcept -> R¶ Overload of operator+ to add the value val to each element of this array and return a new array.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A new array with either this implementation type, or the fallback type.
- Parameters
val
: The value to add to each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator-=
(const Array<ImplOther> &other) noexcept -> Impl&¶ Overload of operator-= to subtract each element of the other array from this array.
- Note
If the sizes of the arrays are different, this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
other
: The array to subtract with.
- Template Parameters
ImplOther
: The implementation type of the subtraction array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator-=
(T val) noexcept -> Impl&¶ Overload of operator-= to subtract the value from each element of this array.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
val
: The value to subtract from each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
, typenameR
= array_impl_t<Impl, ImplOther>>
constexpr autooperator-
(const Array<ImplOther> &other) const noexcept -> R¶ Overload of operator- to subtract each element of the other array from each element in this array, returning a new array.
- Return
A new array with either this implementation type, or the implemenation type of the other array, or the fallback type.
- Parameters
other
: The array for the subtraction.
- Template Parameters
ImplOther
: The implementation type of the subtraction array.
-
template<typename
T
, typenameR
= array_impl_t<Impl, Impl>, array_value_enable_t<T, Impl> = 0>
constexpr autooperator-
(T val) const noexcept -> R¶ Overload of operator- to subtract the value from each element of this array, returning a new array.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A new array with either this implementation type, or the fallback type.
- Parameters
val
: The value to subtract from each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator*=
(const Array<ImplOther> &other) noexcept -> Impl&¶ Overload of operator*= to multiply each element of the other array with this one.
- Note
If the sizes of the arrays are different, this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
other
: The array to multiply with.
- Template Parameters
ImplOther
: The implementation type of the multiplication array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator*=
(T val) noexcept -> Impl&¶ Overload of operator*= to multiply the each element of the array with the value.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
val
: The value to multiply with each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
, typenameR
= array_impl_t<Impl, ImplOther>>
constexpr autooperator*
(const Array<ImplOther> &other) const noexcept -> R¶ Overload of operator* to multiply each element of the array with the other array, returning a new array.
- Return
A new array with either this implementation type, or the implemenation type of the other array, or the fallback type.
- Parameters
other
: The array to multiply with.
- Template Parameters
ImplOther
: The implementation type of the multiplication array.
-
template<typename
T
, typenameR
= array_impl_t<Impl, Impl>, array_value_enable_t<T, Impl> = 0>
constexpr autooperator*
(T val) const noexcept -> R¶ Overload of operator* to multiply the value with each element of this array, returning a new array.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A new array with either this implementation type, or the fallback type.
- Parameters
val
: The value to multiply with each element of the array.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
>
constexpr autooperator/=
(const Array<ImplOther> &other) noexcept -> Impl&¶ Overload of operator/= to divide each element of the array with each element of the other array.
- Note
If the sizes of the arrays are different, this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
other
: The array to divide by.
- Template Parameters
ImplOther
: The implementation type of the other array.
-
template<typename
T
, array_value_enable_t<T, Impl> = 0>
constexpr autooperator/=
(T val) noexcept -> Impl&¶ Overload of operator/= to divide each element in the array by the value.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A reference to the modified array.
- Parameters
val
: The value to divide each element of the array by.
- Template Parameters
T
: The type of the value.
-
template<typename
ImplOther
, typenameR
= array_impl_t<Impl, ImplOther>>
constexpr autooperator/
(const Array<ImplOther> &other) const noexcept -> R¶ Overload of operator/ to divide each element of the array with each element of the other array, returning a new array.
- Note
If the sizes of the arrays are different, this will cause a compile time error.
- Return
A new array with either this implementation type, or the implemenation type of the other array, or the fallback type.
- Parameters
other
: The array to divide by.
- Template Parameters
ImplOther
: The implementation type of the division array.
-
template<typename
T
, typenameR
= array_impl_t<Impl, Impl>, array_value_enable_t<T, Impl> = 0>
constexpr autooperator/
(T val) const noexcept -> R¶ Overload of operator/ to divide each element of this array by the value.
- Note
If the type T cannot be converted to the value type of the array then this will cause a compile time error.
- Return
A new array with either this implementation type, or the fallback type.
- Parameters
val
: The value to multiply with each element of the array.
- Template Parameters
T
: The type of the value.
Public Static Attributes
-
constexpr size_t
elements
= array_traits_t<Impl>::size¶ The number of elements in the array.