21 #ifndef RFFGEN_UTIL_COMPUTE_CHAIN_HH
22 #define RFFGEN_UTIL_COMPUTE_CHAIN_HH
25 #include "consistencyCheck.hh"
26 #include "indexedType.hh"
35 template <
class F,
class IndexedX,
bool allPresent,
36 class X =
typename IndexedX::type,
37 int id = IndexedX::index>
38 struct ComputeChainD1Impl
40 static constexpr
bool present =
false;
41 ComputeChainD1Impl(
const F&,
const X&) {}
44 template <
class F,
class IndexedX,
class IndexedY,
bool allPresent,
45 class X =
typename IndexedX::type,
46 class Y =
typename IndexedY::type,
47 int idx = IndexedX::index,
48 int idy = IndexedY::index>
49 struct ComputeChainD2Impl
51 static constexpr
bool present =
false;
52 ComputeChainD2Impl(
const F&,
const X&,
const Y&) {}
55 template <
class F,
class IndexedX,
class IndexedY,
class IndexedZ,
bool allPresent,
56 class X =
typename IndexedX::type,
57 class Y =
typename IndexedY::type,
58 class Z =
typename IndexedZ::type,
59 int idx = IndexedX::index,
60 int idy = IndexedY::index,
61 int idz = IndexedZ::index>
62 struct ComputeChainD3Impl
64 static constexpr
bool present =
false;
65 ComputeChainD3Impl(
const F&,
const X&,
const Y&,
const Z&) {}
69 template <
class F,
class IndexedX,
class X,
int id>
70 struct ComputeChainD1Impl<F,IndexedX,true,X,id>
72 static constexpr
bool present =
true;
74 ComputeChainD1Impl(
const F& f,
const X& x) : value(f.template d1<id>(x()))
77 auto operator()()
const
82 decltype(std::declval<F>().
template d1<id>(std::declval<X>()())) value;
85 template <class F, class IndexedX, class IndexedY, class X, class Y,
int idx,
int idy>
86 struct ComputeChainD2Impl<F,IndexedX,IndexedY,true,X,Y,idx,idy>
88 static constexpr
bool present =
true;
90 ComputeChainD2Impl(
const F& f,
const X& x,
const Y& y) : value(f.template d2<idx,idy>(x(),y()))
93 auto operator()()
const
98 decltype( std::declval<F>().
template d2<idx,idy>( std::declval<X>()() , std::declval<Y>()() ) ) value;
101 template <class F, class IndexedX, class IndexedY, class IndexedZ, class X, class Y, class Z,
int idx,
int idy,
int idz>
102 struct ComputeChainD3Impl<F,IndexedX,IndexedY,IndexedZ,true,X,Y,Z,idx,idy,idz>
104 static constexpr
bool present =
true;
106 ComputeChainD3Impl(
const F& f,
const X& x,
const Y& y,
const Z& z) : value(f.template d3<idx,idy,idz>(x(),y(),z()))
109 auto operator()()
const
114 decltype( std::declval<F>().
template d3<idx,idy,idz>( std::declval<X>()() , std::declval<Y>()() , std::declval<Z>()() ) ) value;
118 template < class F , class X , class IndexedArg ,
119 class IndexedX = IndexedType<X,IndexedArg::index> >
120 struct ComputeChainD1 : public Detail::ComputeChainD1Impl<F,IndexedX,HasD1MemberFunction<F,IndexedArg>::value && X::present>
122 ComputeChainD1(F
const& f, X
const& x)
123 : Detail::ComputeChainD1Impl<F,IndexedX,HasD1MemberFunction<F,IndexedArg>::value && X::present> (f,x)
127 template <
class F ,
class X ,
class Y ,
class IndexedArgX ,
class IndexedArgY ,
128 class IndexedX = IndexedType<X,IndexedArgX::index> ,
129 class IndexedY = IndexedType<Y,IndexedArgY::index> >
130 struct ComputeChainD2
131 :
public Detail::ComputeChainD2Impl<F,IndexedX,IndexedY,HasD2MemberFunction<F,IndexedArgX,IndexedArgY>::value && X::present && Y::present>
133 ComputeChainD2(
const F& f,
const X& x,
const Y& y)
134 : Detail::ComputeChainD2Impl<F,IndexedX,IndexedY,HasD2MemberFunction< F , IndexedArgX , IndexedArgY >::value && X::present && Y::present >
139 template <
class F ,
class X ,
class Y ,
class Z ,
class IndexedArgX ,
class IndexedArgY ,
class IndexedArgZ ,
140 class IndexedX = IndexedType<X,IndexedArgX::index> ,
141 class IndexedY = IndexedType<Y,IndexedArgY::index> ,
142 class IndexedZ = IndexedType<Z,IndexedArgZ::index> >
143 struct ComputeChainD3
144 :
public Detail::ComputeChainD3Impl<F,IndexedX,IndexedY,IndexedZ,HasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ>::value && X::present && Y::present && Z::present>
146 ComputeChainD3(
const F& f,
const X& x,
const Y& y,
const Z& z)
147 : Detail::ComputeChainD3Impl<F,IndexedX,IndexedY,IndexedZ,HasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ>::value && X::present && Y::present && Z::present> (f,x,y,z)
155 #endif // RFFGEN_UTIL_COMPUTE_CHAIN_HH