gogagum

FilterImpl

Dec 22nd, 2021
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. template <template <typename Arg> class P, TypeList TL>
  2.     struct FilterImpl{
  3.         using Ret = Nil;
  4.     };
  5.  
  6.     template <template <typename> class P, TypeSequence TS>
  7.     struct FilterImpl<P, TS> {
  8.     private:
  9.         template <typename T>
  10.         using NotP = ApplyLogicNotToValue<P<T>>;
  11.  
  12.         using Skipped = typename Impl::SkipWhileImpl<NotP, TS>::Ret;  // Skip all args for which P is false.
  13.  
  14.         template <TypeList TL_>
  15.         struct AfterSkip;
  16.  
  17.         template <TypeSequence TS_>
  18.         struct AfterSkip<TS_> {
  19.             using Head = typename TS_::Head;
  20.             using Tail = typename FilterImpl<P, typename TS_::Tail>::Ret;
  21.         };
  22.  
  23.         template <Empty TE>
  24.         struct AfterSkip<TE> : Nil {};
  25.     public:
  26.         using Ret = AfterSkip<Skipped>;
  27.     };
Advertisement
Add Comment
Please, Sign In to add comment