DUNE-ACFEM (unstable)

runtimeequal.hh
1#ifndef __DUNE_ACFEM_EXPRESSIONS_RUNTIMEEQUAL_HH__
2#define __DUNE_ACFEM_EXPRESSIONS_RUNTIMEEQUAL_HH__
3
4#include "decay.hh"
5#include "storage.hh"
6#include "interface.hh"
7#include "terminal.hh"
8#include "transform.hh"
9#include "../common/literals.hh"
10
11namespace Dune
12{
13
14 namespace ACFem
15 {
16
17 namespace Expressions
18 {
19
31 template<class T, class SFINAE = void>
32 struct IsRuntimeEqual
33 : FalseType
34 {};
35
36 template<class T, class SFINAE = void>
37 struct IsBasicRuntimeEqual
38 : FalseType
39 {};
40
41 template<class T>
42 struct IsBasicRuntimeEqual<
43 T,
44 std::enable_if_t<(!IsSubExpressionExpression<T>::value
45 && (IsTypedValue<T>::value
46 || IsIndeterminateExpression<T>::value
47 || HasTag<T, RuntimeEqualExpression>::value)
48 )> >
49 : TrueType
50 {};
51
52 namespace {
53
54 template<std::size_t ArgIdx, class T, class SFINAE = void>
55 struct IsRTEqualOperand
56 : FalseType
57 {};
58
59 template<std::size_t ArgIdx, class T>
60 struct IsRTEqualOperand<
61 ArgIdx,
62 T,
63 std::enable_if_t<IsRuntimeEqual<std::enable_if_t<!IsSelfExpression<T>::value, Operand<ArgIdx, T> > >::value>
64 >
65 : TrueType
66 {};
67
68 template<class T, class Seq, class SFINAE = void>
69 struct HasRTEqualOperands
70 : FalseType
71 {};
72
73 template<class T, std::size_t... ArgIdx>
74 struct HasRTEqualOperands<
75 T,
76 IndexSequence<ArgIdx...>,
77 std::enable_if_t<AccumulateSequence<LogicalAndFunctor, BoolSequence<IsRTEqualOperand<ArgIdx, T>::value...> >::value>
78 >
79 : TrueType
80 {};
81 }
82
83 template<class T>
84 struct IsRuntimeEqual<T, std::enable_if_t<IsBasicRuntimeEqual<T>::value> >
85 : TrueType
86 {};
87
88 template<class T>
89 struct IsRuntimeEqual<
90 T,
91 std::enable_if_t<(!IsBasicRuntimeEqual<T>::value
92 && IsExpression<T>::value
93 && !IsDynamicOperation<Operation<T> >::value
94 && HasRTEqualOperands<T, MakeIndexSequence<Arity<T>::value> >::value
95 )> >
96 : TrueType
97 {};
98
100 template<class T1, class T2, class SFINAE = void>
102 : std::is_same<DecayExpression<T1>, DecayExpression<T2> >
103 {};
104
108 template<class T1, class T2>
110 T1, T2,
111 std::enable_if_t<(!IsSubExpressionExpression<T1>::value
112 && !IsSubExpressionExpression<T2>::value
113 && (!IsRuntimeEqual<T2>::value || !IsRuntimeEqual<T1>::value)
114 )> >
115 : FalseType
116 {};
117
121 template<class T>
122 struct IsBasicRuntimeEqual<
123 T,
124 std::enable_if_t<IsSubExpressionExpression<T>::value> >
125 : IsRuntimeEqual<Operand<1, T> >
126 {};
127
129 template<class T1, class T2>
131 T1, T2,
132 std::enable_if_t<(IsSubExpressionExpression<T1>::value
133 &&
134 IsSubExpressionExpression<T2>::value)> >
135 : AreRuntimeEqual<Operand<1, T1>, Operand<1, T2> >
136 {};
137
138 template<class T1, class T2>
139 struct AreRuntimeEqual<
140 T1, T2,
141 std::enable_if_t<(IsSubExpressionExpression<T1>::value
142 &&
143 !IsSubExpressionExpression<T2>::value)> >
144 : AreRuntimeEqual<Operand<1, T1>, T2>
145 {};
146
147 template<class T1, class T2>
148 struct AreRuntimeEqual<
149 T1, T2,
150 std::enable_if_t<(!IsSubExpressionExpression<T1>::value
151 &&
152 IsSubExpressionExpression<T2>::value)> >
153 : AreRuntimeEqual<T1, Operand<1, T2> >
154 {};
155
157
159
160 } // Expressions
161
163 template<class T>
164 using IsRuntimeEqualExpression = Expressions::IsRuntimeEqual<T>;
165
167 template<class T1, class T2>
169
170 template<class T>
171 constexpr bool isRuntimeEqualExpression(T&& = T{})
172 {
173 return IsRuntimeEqualExpression<T>::value;
174 }
175
176 template<class T1, class T2>
177 constexpr bool areRuntimeEqualExpressions(T1&& = T1{}, T2&& = T2{})
178 {
179 return AreRuntimeSameExpressions<T1, T2>::value;
180 }
181
182 } // ACFem
183
184} // Dune
185
186#endif // __DUNE_ACFEM_EXPRESSIONS_RUNTIMEEQUAL_HH__
Sequence< std::size_t, V... > IndexSequence
Sequence of std::size_t values.
Definition: types.hh:64
BoolConstant< false > FalseType
Alias for std::false_type.
Definition: types.hh:110
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107
Expressions::IsRuntimeEqual< T > IsRuntimeEqualExpression
Definition: runtimeequal.hh:164
STL namespace.
FalseType by default.
Definition: runtimeequal.hh:103
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)