CVB++ 14.0
LinearValue< T, K > Class Template Reference

This class is memory compatible to K values of type T. More...

#include <cvb/block.hpp>

Public Member Functions

LinearValueoperator= (const LinearValue &) noexcept=default
 Default copy assignment.
 
template<class Ty >
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 class are overwritten by those of other. More...
 
template<std::size_t N>
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 overwritten by those of the initializer list. More...
 
template<class Ty >
Ty Cast () const noexcept
 Cast to any type, for which a set<size_t>(Ty) function exists. More...
 
T & X () noexcept
 Get reference to the first (x) value. More...
 
const T & X () const noexcept
 Get const reference to the first (x) value. More...
 
template<size_t N = K, std::enable_if_t< less< 1, N >::value, int > = 0>
T & Y () noexcept
 Get reference to the second (y) value. More...
 
template<size_t N = K, std::enable_if_t< less< 1, N >::value, int > = 0>
const T & Y () const noexcept
 Get const reference to the second (y) value. More...
 
template<size_t N = K, std::enable_if_t< less< 2, N >::value, int > = 0>
T & Z () noexcept
 Get reference to the third (z) value. More...
 
template<size_t N = K, std::enable_if_t< less< 2, N >::value, int > = 0>
const T & Z () const noexcept
 Get const reference to the third (z) value. More...
 
template<size_t N = K, std::enable_if_t< less< 3, N >::value, int > = 0>
T & W () noexcept
 Get reference to the fourth (w) value. More...
 
template<size_t N = K, std::enable_if_t< less< 3, N >::value, int > = 0>
const T & W () const noexcept
 Get const reference to the fourth (w) value. More...
 
const T & operator[] (size_t i) const noexcept
 Element access. More...
 
T & operator[] (size_t i) noexcept
 Mutable element access. More...
 

Static Public Member Functions

static constexpr const size_t NumValues () noexcept
 Get number of values stored in this LinearValue. More...
 

Related Functions

(Note that these are not member functions.)

template<size_t I, class T , size_t K, std::enable_if_t< less< I, K >::value, int > = 0>
get (const LinearValue< T, K > &linVal) noexcept
 Get's the I-th element of the LinearValue<T,K>. More...
 
template<size_t I, class T , size_t K, std::enable_if_t< less< I, K >::value, int > = 0>
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. More...
 

Detailed Description

template<typename T, size_t K>
class Cvb::LinearValue< T, K >

This class is memory compatible to K values of type T.

See also
Block, Visit

Member Function Documentation

◆ Cast()

Ty Cast ( ) const
inlinenoexcept

Cast to any type, for which a set<size_t>(Ty) function exists.

Template Parameters
TyTarget type, for which a Cvb::set<size_t>(Ty) function exists.
Returns
A newly constructed object of Ty.

◆ NumValues()

static constexpr const size_t NumValues ( )
inlinestaticconstexprnoexcept

Get number of values stored in this LinearValue.

Returns
size_t The number of values K.

◆ operator=() [1/2]

LinearValue< T, K > & operator= ( const T(&)  list[N])
inlinenoexcept

Assignment from a N-element initializer list or array. The values pointed to by this class are overwritten by those of the initializer list.

Template Parameters
NThe number of elements. Must be equal to K.
Parameters
listN-element initializer list or array.
Returns
Reference to this LinearValue.

◆ operator=() [2/2]

LinearValue< T, K > & operator= ( const Ty &  other)
inlinenoexcept

Assignment from any type, for which get<size_t>(Ty) function exists. The values pointed to by this class are overwritten by those of other.

Parameters
[in]otherObject of any type Ty to copy values from. A get<size_t>(Ty) function has to be provided elsewhere and should be defined for 0,..,K-1.
Returns
Reference to this LinearValue.

◆ operator[]() [1/2]

const T & operator[] ( size_t  i) const
inlinenoexcept

Element access.

Parameters
[in]iThe index of the requested element.
Returns
T The value of the i-th element.

◆ operator[]() [2/2]

T & operator[] ( size_t  i)
inlinenoexcept

Mutable element access.

Parameters
[in]iThe index of the requested element.
Returns
T The reference to the i-th element.

◆ W() [1/2]

const T & W ( ) const
inlinenoexcept

Get const reference to the fourth (w) value.

Returns
const reference to the w value.

◆ W() [2/2]

T & W ( )
inlinenoexcept

Get reference to the fourth (w) value.

Returns
Reference to the w value.

◆ X() [1/2]

const T & X ( ) const
inlinenoexcept

Get const reference to the first (x) value.

Returns
const reference to the x value.

◆ X() [2/2]

T & X ( )
inlinenoexcept

Get reference to the first (x) value.

Returns
Reference to the x value.

◆ Y() [1/2]

const T & Y ( ) const
inlinenoexcept

Get const reference to the second (y) value.

Returns
const reference to the y value.

◆ Y() [2/2]

T & Y ( )
inlinenoexcept

Get reference to the second (y) value.

Returns
Reference to the y value.

◆ Z() [1/2]

const T & Z ( ) const
inlinenoexcept

Get const reference to the third (z) value.

Returns
const reference to the z value.

◆ Z() [2/2]

T & Z ( )
inlinenoexcept

Get reference to the third (z) value.

Returns
Reference to the z value.

Friends And Related Function Documentation

◆ get()

T get ( const LinearValue< T, K > &  linVal)
related

Get's the I-th element of the LinearValue<T,K>.

See also
Block, Visit
Precondition
I < K
Template Parameters
IThe index of the element.
Parameters
linValThe LinearValue<T,K> to retrieve the I-th element from.
Returns
The value of the I-th element of linVal.

◆ set()

void set ( LinearValue< T, K > &  linVal,
const T &  val 
)
related

Set's the value of the I-th element in the LinearValue<T,K> linVal.

See also
Block, Visit
Precondition
I < K
Template Parameters
IThe index of the element.
Parameters
linValThe LinearValue<T,K> to retrieve the I-th element from.
valThe value to be written to the I-th element of linVal.