fork(3) download
  1. #include <iostream>
  2. #include <tuple>
  3. #include <type_traits>
  4. using namespace std;
  5.  
  6. template<int Ins, int Outs>
  7. class Filter
  8. {
  9. // implementation
  10. };
  11.  
  12. template <int... Args>
  13. struct FiltersFor;
  14.  
  15. template <typename Tuple1, typename Tuple2>
  16. using tuple_cat_t = decltype(std::tuple_cat(std::declval<Tuple1>(),
  17. std::declval<Tuple2>()));
  18.  
  19. template <int Ins, int Outs, int... Others>
  20. struct FiltersFor<Ins,Outs,Others...>
  21. {
  22. using type = tuple_cat_t<std::tuple<Filter<Ins,Outs>>, typename FiltersFor<Outs,Others...>::type>;
  23. };
  24.  
  25. template <int Dummy>
  26. struct FiltersFor<Dummy>
  27. {
  28. using type = std::tuple<>;
  29. };
  30.  
  31. template <>
  32. struct FiltersFor<>
  33. {
  34. using type = std::tuple<>;
  35. };
  36.  
  37. template<int... args>
  38. using Chain = typename FiltersFor<args...>::type;
  39.  
  40.  
  41. static_assert(std::is_same<Chain<1,2,3,4>, std::tuple<Filter<1,2>,Filter<2,3>,Filter<3,4>>>::value, "wat");
  42. static_assert(std::is_same<Chain<1,2>, std::tuple<Filter<1,2>>>::value, "wat");
  43. static_assert(std::is_same<Chain<>, std::tuple<>>::value, "wat");
  44.  
  45. int main() {
  46. return 0;
  47. }
Success #stdin #stdout 0s 3136KB
stdin
Standard input is empty
stdout
Standard output is empty