3#include "../../shims/stdtype_traits.hpp"
5#include "detail_block.hpp"
16 template <
template <
class,
size_t>
class CRefValue>
23 template <size_t I, class Ty, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
24 static CVB_FORCE_INLINE
void set(CRefValue<Ty, K> &refVal,
const Ty *val)
noexcept
26 refVal.pointers_[I] =
const_cast<Ty *
>(val);
35 template <
template <
class,
size_t>
class RValue>
42 template <size_t I, class Ty, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
43 static CVB_FORCE_INLINE
void set(RValue<Ty, K> &refVal, Ty *val)
noexcept
45 refVal.pointers_[I] = val;
55 template <
class T,
size_t K>
58 static_assert(K > 0,
"Cvb: ConstRefValue must hold at least one element.");
60 template <
class Ty,
class ACCESSTRAIT>
62 template <
template <
class,
size_t>
class CRefValue>
63 friend struct ConstRefValueSetter;
72 for (
auto &ptr : pointers_)
79 using ComponentType = T;
87 template <
class... TT>
89 : pointers_({
const_cast<T *
>(&refs)...})
93 static_assert(
sizeof...(TT) == K,
"Cvb: Number of parameters must equal the number of elements.");
97 ConstRefValue(
const ConstRefValue & other)
noexcept =
default;
98 ConstRefValue &operator=(
const ConstRefValue & other)
noexcept =
default;
99 ConstRefValue(ConstRefValue&& other)
noexcept =
default;
100 ConstRefValue& operator=(ConstRefValue&& other)
noexcept =
default;
101 ~ConstRefValue() =
default;
104 template <
class Ty,
size_t... I>
105 Ty
Cast(std::index_sequence<I...>)
const noexcept
107 using expander =
int[];
111 expander{0, ((void)set<I>(value, *pointers_[I]), 0)...};
125 return Cast<Ty>(std::make_index_sequence<K>());
135 return *pointers_[0];
143 template <size_t N = K, std::enable_if_t<less<1, N>::value,
int> = 0>
146 return *pointers_[1];
154 template <size_t N = K, std::enable_if_t<less<2, N>::value,
int> = 0>
157 return *pointers_[2];
165 template <size_t N = K, std::enable_if_t<less<3, N>::value,
int> = 0>
168 return *pointers_[3];
181 return *pointers_[i];
200 template <
class T,
size_t K>
213 static_assert(K > 0,
"Cvb: RefValue must hold at least one element.");
215 template <
class Ty,
class ACCESSTRAIT>
217 template <
template <
class,
size_t>
class RValue>
218 friend struct RefValueSetter;
227 for (
auto &ptr : pointers_)
234 using ComponentType = T;
241 template <
class... TT>
243 : pointers_({
const_cast<T *
>(&refs)...})
250 RefValue(
const RefValue & other)
noexcept =
default;
251 RefValue &operator=(
const RefValue & other)
noexcept =
default;
252 RefValue(RefValue&& other)
noexcept =
default;
253 RefValue& operator=(RefValue&& other)
noexcept =
default;
254 ~RefValue() =
default;
257 template <
class Ty,
size_t... I>
258 RefValue<T, K> &Assign(
const Ty &other, std::index_sequence<I...>)
noexcept
260 using expander =
int[];
263 expander{0, ((void)(*pointers_[I] = get<I>(other)), 0)...};
280 return Assign(other, std::make_index_sequence<K>());
294 static_assert(N == K,
"Cvb: The initializer list must contain K elements.");
296 for (
int i = 0; i < N; ++i)
298 *pointers_[i] = list[i];
304 template <
class Ty,
size_t... I>
305 Ty
Cast(std::index_sequence<I...>)
const noexcept
307 using expander =
int[];
311 expander{0, ((void)set<I>(value, *pointers_[I]), 0)...};
325 return Cast<Ty>(std::make_index_sequence<K>());
335 return *pointers_[0];
345 return *pointers_[0];
353 template <size_t N = K, std::enable_if_t<less<1, N>::value,
int> = 0>
356 return *pointers_[1];
364 template <size_t N = K, std::enable_if_t<less<1, N>::value,
int> = 0>
367 return *pointers_[1];
375 template <size_t N = K, std::enable_if_t<less<2, N>::value,
int> = 0>
378 return *pointers_[2];
386 template <size_t N = K, std::enable_if_t<less<2, N>::value,
int> = 0>
389 return *pointers_[2];
397 template <size_t N = K, std::enable_if_t<less<3, N>::value,
int> = 0>
400 return *pointers_[3];
408 template <size_t N = K, std::enable_if_t<less<3, N>::value,
int> = 0>
411 return *pointers_[3];
424 return *pointers_[i];
437 return *pointers_[i];
463 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
481 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
499 template <size_t I, class T, size_t K, std::enable_if_t<less<I, K>::value,
int> = 0>
522 template <
size_t I,
class Ty,
size_t K>
525 assert(val !=
nullptr);
527 RefValueSetter<RefValue>::template set<I>(refVal, val);
546 template <
size_t I,
class Ty,
size_t K>
549 assert(val !=
nullptr);
551 ConstRefValueSetter<ConstRefValue>::template set<I>(refVal, val);
Non-owning view on a 2d-plane of data.
Definition: decl_block.hpp:23
This class holds references to K values of type T.
Definition: block_helper_ref_value.hpp:57
ConstRefValue(const TT &... refs)
Constructor from reference values.
Definition: block_helper_ref_value.hpp:88
T X() const noexcept
Get const value of the first (x) value.
Definition: block_helper_ref_value.hpp:133
T W() const noexcept
Get const value of the fourth (w) value.
Definition: block_helper_ref_value.hpp:166
Ty Cast() const noexcept
Cast to any type, for which a set<size_t>(Ty) function exists.
Definition: block_helper_ref_value.hpp:123
T Z() const noexcept
Get const value of the third (z) value.
Definition: block_helper_ref_value.hpp:155
static constexpr size_t NumValues() noexcept
Get number of values stored in this ConstRefValue.
Definition: block_helper_ref_value.hpp:189
T operator[](size_t i) const noexcept
Element access.
Definition: block_helper_ref_value.hpp:177
auto get(const ConstRefValue< T, K > &refVal) noexcept -> decltype(refVal[I])
Get's the I-th element of the ConstRefValue<T,K>.
Definition: block_helper_ref_value.hpp:482
T Y() const noexcept
Get const value of the second (y) value.
Definition: block_helper_ref_value.hpp:144
CVB_FORCE_INLINE void internal_set(ConstRefValue< Ty, K > &refVal, const Ty *val) noexcept
Definition: block_helper_ref_value.hpp:547
This class holds mutable references to K values of type T.
Definition: block_helper_ref_value.hpp:202
void set(RefValue< T, K > &refVal, const T &val) noexcept
Set's the value of the I-th element in the RefValue<T,K> refVal.
Definition: block_helper_ref_value.hpp:500
T X() const noexcept
Get const value of the first (x) value.
Definition: block_helper_ref_value.hpp:333
T & Y() noexcept
Get reference to the second (y) value.
Definition: block_helper_ref_value.hpp:365
T W() const noexcept
Get const value of the fourth (w) value.
Definition: block_helper_ref_value.hpp:398
Ty Cast() const noexcept
Cast to any type, for which a set<size_t>(Ty) function exists.
Definition: block_helper_ref_value.hpp:323
CVB_FORCE_INLINE void internal_set(RefValue< Ty, K > &refVal, Ty *val) noexcept
Definition: block_helper_ref_value.hpp:523
T & X() noexcept
Get reference to the first (x) value.
Definition: block_helper_ref_value.hpp:343
T Z() const noexcept
Get const value of the third (z) value.
Definition: block_helper_ref_value.hpp:376
RefValue< 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_ref_value.hpp:292
RefValue(TT &... refs)
Constructor from reference values.
Definition: block_helper_ref_value.hpp:242
T & W() noexcept
Get reference to the fourth (w) value.
Definition: block_helper_ref_value.hpp:409
T operator[](size_t i) const noexcept
Element access.
Definition: block_helper_ref_value.hpp:420
T & Z() noexcept
Get reference to the third (z) value.
Definition: block_helper_ref_value.hpp:387
T & operator[](size_t i) noexcept
Mutable element access.
Definition: block_helper_ref_value.hpp:433
T Y() const noexcept
Get const value of the second (y) value.
Definition: block_helper_ref_value.hpp:354
static constexpr const size_t NumValues() noexcept
Get number of values stored in this RefValue.
Definition: block_helper_ref_value.hpp:445
RefValue< 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_ref_value.hpp:278
auto get(const RefValue< T, K > &refVal) noexcept -> decltype(refVal[I])
Get's the I-th element of the RefValue<T,K>.
Definition: block_helper_ref_value.hpp:464
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
Helper class for setting the pointers, as friending template functions is not really stable.
Definition: block_helper_ref_value.hpp:18
static CVB_FORCE_INLINE void set(CRefValue< Ty, K > &refVal, const Ty *val) noexcept
Definition: block_helper_ref_value.hpp:24
Helper class for setting the pointers, as friending template functions is not really stable.
Definition: block_helper_ref_value.hpp:37
static CVB_FORCE_INLINE void set(RValue< Ty, K > &refVal, Ty *val) noexcept
Definition: block_helper_ref_value.hpp:43