DUNE-ACFEM (unstable)

filter.hh
1 #ifndef __DUNE_ACFEM_MPL_FILTER_HH__
2 #define __DUNE_ACFEM_MPL_FILTER_HH__
3 
4 #include "transform.hh"
5 
6 namespace Dune {
7 
8  namespace ACFem {
9 
50  template<class F, class Input>
52  {
53  template<class Tin, Tin V, class Tout, Tout FV, std::size_t N>
54  struct Apply
55  : BoolConstant<F::template Apply<Tin, V, N>::value>
56  {};
57  };
58 
60  template<typename Int, Int... I0, Int... I1>
62  {
63  return Sequence<Int, I0..., I1...>{};
64  }
65 
70  template<typename Int, Int... I0, Int... I1, class Seq, class... RestSeq>
71  constexpr auto sequenceCat(Sequence<Int, I0...>, Sequence<Int, I1...>, Seq, RestSeq...)
72  {
73  return sequenceCat(Sequence<Int, I0..., I1...>{}, Seq{}, RestSeq{}...);
74  }
75 
77  template<class Seq>
78  constexpr auto sequenceCat(Seq)
79  {
80  return Seq{};
81  }
82 
114  template<class F, class Seq>
116 
123  struct UnaryAcceptAllFunctor
124  {
125  template<class T, T>
126  using Apply = TrueType;
127  };
128 
132  template<class F>
134  {
135  template<class T, T V, std::size_t N>
136  struct Apply
137  : BoolConstant<!F::template Apply<T, V, N>::value>
138  {};
139  };
140 
142  template<std::size_t... Indices>
144  {
145  template<class T, T V, std::size_t N>
146  struct Apply
147  : ContainsValue<IndexSequence<Indices...>, N>
148  {};
149  };
150 
152 
153  namespace {
154  template<std::size_t N, class S1, class S2>
155  struct CommonHeadHelper
156  {
157  static constexpr std::size_t value = N;
158  };
159 
160  template<std::size_t N,
161  class T, T Head, T... Rest1, T... Rest2>
162  struct CommonHeadHelper<N, Sequence<T, Head, Rest1...>, Sequence<T, Head, Rest2...> >
163  {
164  static constexpr std::size_t value =
165  CommonHeadHelper<N+1, Sequence<T, Rest1...>, Sequence<T, Rest2...> >::value;
166  };
167  }
168 
172  template<class Seq1, class Seq2>
174 
176 
178 
180 
181  } // ACFem::
182 
183 } // Dune::
184 
185 #endif // __DUNE_ACFEM_MPL_FILTER_HH__
IndexConstant< CommonHeadHelper< 0UL, Seq1, Seq2 >::value > CommonHead
Compute the number of identical indices at the head of the sequence.
Definition: filter.hh:173
constexpr auto sequenceCat(Sequence< Int, I0... >, Sequence< Int, I1... >)
Definition: filter.hh:61
TransformSequence< Seq, Sequence< typename Seq::value_type >, IdentityFunctor, UnaryFilterFunctor< F, typename Seq::value_type > > FilteredSequence
Create a new sequence by filtering out certain elements.
Definition: filter.hh:115
typename TransformSequenceHelper< SeqIn, SeqOut, TransformFunctor, AcceptFunctor >::Type TransformSequence
General sequence transformation alias.
Definition: transform.hh:172
Constant< bool, V > BoolConstant
Short-cut for integral constant of type bool.
Definition: types.hh:48
std::integer_sequence< T, V... > Sequence
Sequence of any type of integer values.
Definition: types.hh:56
Constant< std::size_t, V > IndexConstant
Short-cut for integral constant of type std::size_t.
Definition: types.hh:44
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107
Identity functor.
Definition: transform.hh:316
Filter-proxy for TransformSequence template alias.
Definition: filter.hh:52
Alternative: avoid bit-masks and use ContainsValue<> template.
Definition: filter.hh:144
Negate a given unary functor.
Definition: filter.hh:134
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (Apr 26, 22:29, 2024)