3#include "detail_block.hpp"
9 template <
typename T,
size_t K>
24 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
39 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
48 template <
typename T,
size_t K>
49 class LinearValue final
51 template <
class TTY,
class ACCESSTRAITT>
57 using ComponentType = T;
64 LinearValue() =
default;
66 LinearValue(
const LinearValue &other)
noexcept =
default;
67 LinearValue &operator=(
const LinearValue &other)
noexcept =
default;
68 LinearValue(LinearValue &&other)
noexcept =
default;
69 LinearValue &operator=(LinearValue &&other)
noexcept =
default;
70 ~LinearValue() =
default;
73 template <
class Ty,
size_t... I>
74 LinearValue<T, K> &Assign(
const Ty &other, std::index_sequence<I...>)
noexcept
76 using expander =
int[];
79 expander{0, ((void)(values_[I] =
get<I>(other)), 0)...};
94 LinearValue<T, K> &
operator=(
const Ty &other)
noexcept
96 return Assign(other, std::make_index_sequence<K>());
107 template <std::
size_t N>
108 LinearValue<T, K> &
operator=(
const T (&list)[N])
noexcept
110 static_assert(N == K,
"Cvb: The initializer list must contain K elements.");
112 for (
int i = 0; i < N; ++i)
114 values_[i] = list[i];
120 template <
class Ty,
size_t... I>
121 Ty
Cast(std::index_sequence<I...>)
const noexcept
123 using expander =
int[];
127 expander{0, ((void)
set<I>(value, values_[I]), 0)...};
141 return Cast<Ty>(std::make_index_sequence<K>());
159 const T &
X() const noexcept
169 template <size_t N = K, std::enable_if_t<less<1, N>::value,
int> = 0>
180 template <size_t N = K, std::enable_if_t<less<1, N>::value,
int> = 0>
181 const T &
Y() const noexcept
191 template <size_t N = K, std::enable_if_t<less<2, N>::value,
int> = 0>
202 template <size_t N = K, std::enable_if_t<less<2, N>::value,
int> = 0>
203 const T &
Z() const noexcept
213 template <size_t N = K, std::enable_if_t<less<3, N>::value,
int> = 0>
224 template <size_t N = K, std::enable_if_t<less<3, N>::value,
int> = 0>
225 const T &
W() const noexcept
268 static_assert(
sizeof(LinearValue<float, 1>) == 1 *
sizeof(float),
"LinearValue is not packed");
269 static_assert(
sizeof(LinearValue<float, 2>) == 2 *
sizeof(float),
"LinearValue is not packed");
270 static_assert(
sizeof(LinearValue<float, 3>) == 3 *
sizeof(float),
"LinearValue is not packed");
271 static_assert(
sizeof(LinearValue<float, 4>) == 4 *
sizeof(float),
"LinearValue is not packed");
272 static_assert(
sizeof(LinearValue<double, 5>) == 5 *
sizeof(double),
"LinearValue is not packed");
274 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int>>
275 T
get(
const LinearValue<T, K> &linVal)
noexcept
280 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int>>
281 void set(LinearValue<T, K> &linVal,
const T &val)
noexcept
299 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
302 assert(val !=
nullptr);
This class is memory compatible to K values of type T.
Definition block_helper_linear_value.hpp:50
LinearValue< T, K > & operator=(const Ty &other) noexcept
Assignment from any type, for which get<size_t>(Ty) function exists. The values pointed to by this cl...
Definition block_helper_linear_value.hpp:94
T & Y() noexcept
Get reference to the second (y) value.
Definition block_helper_linear_value.hpp:170
Ty Cast() const noexcept
Cast to any type, for which a set<size_t>(Ty) function exists.
Definition block_helper_linear_value.hpp:139
T & X() noexcept
Get reference to the first (x) value.
Definition block_helper_linear_value.hpp:149
const T & X() const noexcept
Get const reference to the first (x) value.
Definition block_helper_linear_value.hpp:159
T & W() noexcept
Get reference to the fourth (w) value.
Definition block_helper_linear_value.hpp:214
const T & Z() const noexcept
Get const reference to the third (z) value.
Definition block_helper_linear_value.hpp:203
const T & W() const noexcept
Get const reference to the fourth (w) value.
Definition block_helper_linear_value.hpp:225
LinearValue< T, K > & operator=(const T(&list)[N]) noexcept
Assignment from a N-element initializer list or array. The values pointed to by this class are overwr...
Definition block_helper_linear_value.hpp:108
const T & operator[](size_t i) const noexcept
Element access.
Definition block_helper_linear_value.hpp:236
T & Z() noexcept
Get reference to the third (z) value.
Definition block_helper_linear_value.hpp:192
T get(const LinearValue< T, K > &linVal) noexcept
Get's the I-th element of the LinearValue<T,K>.
Definition block_helper_linear_value.hpp:275
void set(LinearValue< T, K > &linVal, const T &val) noexcept
Set's the value of the I-th element in the LinearValue<T,K> linVal.
Definition block_helper_linear_value.hpp:281
T & operator[](size_t i) noexcept
Mutable element access.
Definition block_helper_linear_value.hpp:249
static constexpr const size_t NumValues() noexcept
Get number of values stored in this LinearValue.
Definition block_helper_linear_value.hpp:261
const T & Y() const noexcept
Get const reference to the second (y) value.
Definition block_helper_linear_value.hpp:181
Root namespace for the Image Manager interface.
Definition version.hpp:11