redefrec

MetaSeq

Jun 8th, 2018
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module meta.seq;
  2.  
  3. public import std.meta;
  4.  
  5. bool Contains (alias Elem, Seq...)() {
  6.     return staticIndexOf!(Elem, Seq) >= 0;
  7. }
  8.  
  9. template ApplyContains (Seq...) {
  10.     template Applied (alias Elem) {
  11.         alias Applied = Contains!(Elem, Seq);
  12.     }
  13. }
  14.  
  15. template Intersect (Left...) {
  16.     template To (Right...) {
  17.         alias To = Filter!(ApplyContains!(Right).Applied, Left);
  18.     }
  19. }
  20.  
  21. template Difference (Left...) {
  22.     template To (Right...) {
  23.         alias To = Filter!(templateNot!(ApplyContains!(Right).Applied), Left);
  24.     }
  25. }
RAW Paste Data