21 #ifndef RFFGEN_UTIL_DERIVATIVE_WRAPPERS_HH
22 #define RFFGEN_UTIL_DERIVATIVE_WRAPPERS_HH
24 #include <type_traits>
27 #include "consistencyCheck.hh"
37 template <
class F,
class IndexedArg,
bool IsPresent,
38 class Arg =
typename IndexedArg::type,
39 int id = IndexedArg::index>
42 static constexpr
bool present =
false;
44 D1Impl(F
const&,
const Arg&){}
45 D1Impl(
const D1Impl&) =
delete;
46 D1Impl& operator=(
const D1Impl&) =
delete;
50 template <
class F,
class IndexedArg,
class Arg,
int id>
51 struct D1Impl<F,IndexedArg,true,Arg,id>
53 static constexpr
bool present =
true;
57 D1Impl(
const F& f,
const Arg& dx) : value(f.template d1<id>(dx)) {}
59 auto operator()() const -> decltype(std::declval<F>().template d1<
id>(std::declval<Arg>()))
64 D1Impl(
const D1Impl&) =
delete;
65 D1Impl& operator=(
const D1Impl&) =
delete;
68 decltype(std::declval<F>().
template d1<id>(std::declval<Arg>())) value;
73 template < class F , class IndexedArgX , class IndexedArgY ,
bool IsPresent ,
74 class ArgX = typename IndexedArgX::type ,
75 class ArgY = typename IndexedArgY::type ,
76 int idx = IndexedArgX::index ,
77 int idy = IndexedArgY::index >
80 static constexpr
bool present =
false;
82 D2Impl(
const F&,
const ArgX&,
const ArgY&){}
83 D2Impl(
const D2Impl&) =
delete;
84 D2Impl& operator=(
const D2Impl&) =
delete;
88 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
class ArgX ,
class ArgY ,
int idx ,
int idy >
89 struct D2Impl<F,IndexedArgX,IndexedArgY,true,ArgX,ArgY,idx,idy>
91 static constexpr
bool present =
true;
95 D2Impl(
const F& f,
const ArgX& dx,
const ArgY& dy) : value(f.template d2<idx,idy>(dx,dy)) {}
97 auto operator()() const -> decltype(std::declval<F>().template d2<idx,idy>(std::declval<ArgX>(),std::declval<ArgY>()))
102 D2Impl(
const D2Impl&) =
delete;
103 D2Impl& operator=(
const D2Impl&) =
delete;
106 decltype(std::declval<F>().
template d2<idx,idy>(std::declval<ArgX>(),std::declval<ArgY>())) value;
111 template < class F , class IndexedArgX , class IndexedArgY , class IndexedArgZ ,
bool IsPresent ,
112 class ArgX = typename IndexedArgX::type ,
113 class ArgY = typename IndexedArgY::type ,
114 class ArgZ = typename IndexedArgZ::type ,
115 int idx = IndexedArgX::index ,
116 int idy = IndexedArgY::index ,
117 int idz = IndexedArgZ::index >
120 static constexpr
bool present =
false;
122 D3Impl(
const F&,
const ArgX&,
const ArgY&,
const ArgZ&){}
123 D3Impl(
const D3Impl&) =
delete;
124 D3Impl& operator=(
const D3Impl&) =
delete;
128 template <
class F,
class IndexedArgX,
class IndexedArgY,
class IndexedArgZ,
class ArgX,
class ArgY,
class ArgZ,
int idx,
int idy,
int idz>
129 struct D3Impl<F,IndexedArgX,IndexedArgY,IndexedArgZ,true,ArgX,ArgY,ArgZ,idx,idy,idz>
131 static constexpr
bool present =
true;
135 D3Impl(
const F& f,
const ArgX& dx,
const ArgY& dy,
const ArgZ& dz) : value(f.template d3<idx,idy,idz>(dx,dy,dz)) {}
137 auto operator()() const -> decltype(std::declval<F>().template d3<idx,idy,idz>(std::declval<ArgX>(),std::declval<ArgY>(),std::declval<ArgZ>()))
142 D3Impl(
const D3Impl&) =
delete;
143 D3Impl& operator=(
const D3Impl&) =
delete;
146 decltype(std::declval<F>().
template d3<idx,idy,idz>(std::declval<ArgX>(),std::declval<ArgY>(),std::declval<ArgZ>())) value;
154 static constexpr
bool present = HasD0MemberFunction<F>();
158 D0(
const F& f) : value(f.d0()) {}
160 auto operator()() const ->decltype(std::declval<F>().d0())
165 D0(
const D0&) =
delete;
166 D0& operator=(
const D0&) =
delete;
169 decltype(std::declval<F>().d0()) value;
173 template < class F, class IndexedArg >
174 using D1 = Detail::D1Impl<F,IndexedArg,HasD1MemberFunction<F,IndexedArg>::value>;
177 template < class F , class IndexedArgX , class IndexedArgY >
178 using D2 = Detail::D2Impl<F,IndexedArgX,IndexedArgY,HasD2MemberFunction<F,IndexedArgX,IndexedArgY>::value>;
181 template < class F , class IndexedArgX , class IndexedArgY , class IndexedArgZ >
182 using D3 = Detail::D3Impl<F,IndexedArgX,IndexedArgY,IndexedArgZ,HasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ>::value>;
188 #endif // RFFGEN_UTIL_DERIVATIVE_WRAPPERS_HH