21 #ifndef RFFGEN_UTIL_AT_HH
22 #define RFFGEN_UTIL_AT_HH
24 #include <type_traits>
37 template <
class Matrix,
bool accessViaSquareBrackets,
bool accessViaRoundBrackets,
bool isMatrix>
40 template <
class Matrix,
bool accessViaRoundBrackets>
41 struct ValueTypeImpl<Matrix,true,accessViaRoundBrackets,true>
43 using type = decltype(std::declval<Matrix>()[0][0]);
46 template <
class Matrix>
47 struct ValueTypeImpl<Matrix,false,true,true>
49 using type = decltype(std::declval<Matrix>()(0,0));
52 template <
class Vector,
bool accessViaRoundBrackets>
53 struct ValueTypeImpl<Vector,true,accessViaRoundBrackets,false>
55 using type = decltype(std::declval<Vector>()[0]);
58 template <
class Vector>
59 struct ValueTypeImpl<Vector,false,true,false>
61 using type = decltype(std::declval<Vector>()(0));
64 template <
class Matrix>
65 using ValueType = ValueTypeImpl<Matrix,Checks::accessViaSquareBrackets<Matrix>(),Checks::accessViaRoundBrackets<Matrix>(),Checks::isConstantSizeMatrix<Matrix>()>;
68 template <
class Matrix,
class =
void>
71 static auto& apply(Matrix& A,
int i,
int j)
77 template <
class Matrix>
78 struct At< Matrix ,
void_t< Checks::TryAccessViaSquareBracketsForMatrix<Matrix> > >
80 static auto& apply(Matrix& A,
int i,
int j)
86 template <
class Vector,
class =
void>
89 static auto& apply(Vector& v,
int i)
95 template <
class Vector>
96 struct At_v< Vector ,
void_t< Checks::AccessViaSquareBracketsForVector<Vector> > >
98 static auto& apply(Vector& v,
int i)
107 using at_t =
typename AtDetail::ValueType<Arg>::type;
110 template <
class Matrix>
111 __attribute__((always_inline)) auto& at(Matrix& A,
int i,
int j)
113 return AtDetail::At<Matrix>::apply(A,i,j);
116 template <
class Vector>
117 __attribute__((always_inline)) auto& at(Vector& v,
int i)
119 return AtDetail::At_v<Vector>::apply(v,i);
126 #endif // RFFGEN_UTIL_AT_HH
typename Detail::voider< Types...>::type void_t
Most fascinating type ever. Is always void.
Definition: voider.hh:40
Static checks for detection of presence of different operators and functions.