21 #ifndef RFFGEN_UTIL_CONSISTENCY_CHECK_HH
22 #define RFFGEN_UTIL_CONSISTENCY_CHECK_HH
24 #include <type_traits>
33 template <
class F ,
class =
void >
35 struct HasD0MemberFunction : std::false_type {};
38 template <
class F ,
class IndexedArg ,
class =
void>
39 struct HasD1MemberFunction : std::false_type {};
42 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
class =
void >
43 struct HasD2MemberFunction : std::false_type {};
46 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
class IndexedArgZ ,
class =
void>
47 struct HasD3MemberFunction : std::false_type {};
54 template <
class F>
using check_d0_member_presence_t = decltype(std::declval<F>().d0());
57 template <
class F ,
class IndexedArg ,
58 class Arg =
typename IndexedArg::type ,
59 int id = IndexedArg::index >
60 using check_d1_member_presence_t = decltype(std::declval<F>().
template d1<id>(std::declval<Arg>()));
63 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
64 class ArgX =
typename IndexedArgX::type ,
65 class ArgY =
typename IndexedArgY::type ,
66 int idx = IndexedArgX::index ,
67 int idy = IndexedArgY::index >
68 using check_d2_member_presence_t = decltype(std::declval<F>().
template d2<idx,idy>(std::declval<ArgX>(),std::declval<ArgY>()));
71 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
class IndexedArgZ ,
72 class ArgX =
typename IndexedArgX::type ,
73 class ArgY =
typename IndexedArgY::type ,
74 class ArgZ =
typename IndexedArgZ::type ,
75 int idx = IndexedArgX::index ,
76 int idy = IndexedArgY::index ,
77 int idz = IndexedArgZ::index >
78 using check_d3_member_presence_t = decltype(std::declval<F>().
template d3<idx,idy,idz>(std::declval<ArgX>(),std::declval<ArgY>(),std::declval<ArgZ>()));
83 template <
bool presence_of_d0 = false,
bool presence_of_d1 = false,
bool presence_of_d2 = false,
bool presence_of_d3 = false>
84 struct ConsistentDerivatives : std::false_type {};
87 template <>
struct ConsistentDerivatives<true,true,true,true> : std::true_type {};
90 template <>
struct ConsistentDerivatives<true,true,true,false> : std::true_type {};
93 template <>
struct ConsistentDerivatives<true,true,false,false> : std::true_type {};
96 template <>
struct ConsistentDerivatives<true,false,false,false> : std::true_type {};
100 template <
bool presence_of_d0 = false,
bool presence_of_d1 = false,
bool presence_of_d2 = false,
bool presence_of_d3 = false>
101 struct NumberOfDerivatives : std::integral_constant<int,-1> {};
104 template <>
struct NumberOfDerivatives<true,true,true,true> : std::integral_constant<int,3> {};
107 template <>
struct NumberOfDerivatives<true,true,true,false> : std::integral_constant<int,2> {};
110 template <>
struct NumberOfDerivatives<true,true,false,false> : std::integral_constant<int,1> {};
113 template <>
struct NumberOfDerivatives<true,false,false,false> : std::integral_constant<int,0> {};
126 struct HasD0MemberFunction<F,
void_t<Detail::check_d0_member_presence_t<F> > >
131 template <
class F ,
class IndexedArg >
132 struct HasD1MemberFunction<F,IndexedArg,
void_t<Detail::check_d1_member_presence_t<F,IndexedArg> > >
137 template <
class F ,
class IndexedArgX ,
class IndexedArgY >
138 struct HasD2MemberFunction<F,IndexedArgX,IndexedArgY,
void_t<Detail::check_d2_member_presence_t<F,IndexedArgX,IndexedArgY> > >
143 template <
class F,
class IndexedArgX,
class IndexedArgY,
class IndexedArgZ>
144 struct HasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ,
void_t<Detail::check_d3_member_presence_t<F,IndexedArgX,IndexedArgY,IndexedArgZ> > >
149 constexpr
bool hasD0MemberFunction() {
return HasD0MemberFunction<F>::value; }
151 template <
class F ,
class IndexedArgX >
152 constexpr
bool hasD1MemberFunction() {
return HasD1MemberFunction<F,IndexedArgX>::value; }
154 template <
class F ,
class IndexedArgX ,
class IndexedArgY >
155 constexpr
bool hasD2MemberFunction() {
return HasD2MemberFunction<F,IndexedArgX,IndexedArgY>::value; }
157 template <
class F ,
class IndexedArgX ,
class IndexedArgY ,
class IndexedArgZ >
158 constexpr
bool hasD3MemberFunction() {
return HasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ>::value; }
161 constexpr
bool hasConsistentFirstDerivative()
163 return hasD0MemberFunction<F>();
166 template <
class F ,
class IndexedArgX ,
class IndexedArgY >
167 constexpr
bool hasConsistentSecondDerivative()
169 return hasConsistentFirstDerivative<F>() &&
170 ( hasD2MemberFunction<F,IndexedArgX,IndexedArgY>() ? hasD1MemberFunction<F,IndexedArgX>() :
true );
173 template <
class F,
class IndexedArgX ,
class IndexedArgY ,
class IndexedArgZ >
174 constexpr
bool hasConsistentThirdDerivative()
176 return hasConsistentSecondDerivative<F,IndexedArgX,IndexedArgY>() &&
177 ( hasD3MemberFunction<F,IndexedArgX,IndexedArgY,IndexedArgZ>() ? hasD2MemberFunction<F,IndexedArgX,IndexedArgY>() :
true );
200 #endif // RFFGEN_UTIL_CONSISTENCY_CHECK_HH
typename Detail::voider< Types...>::type void_t
Most fascinating type ever. Is always void.
Definition: voider.hh:40