fork(6) download
  1. // using aliases for cleaner syntax
  2. template<class T> using Invoke = typename T::type;
  3.  
  4. template<unsigned...> struct seq{ using type = seq; };
  5.  
  6. template<class S1, class S2> struct concat;
  7.  
  8. template<unsigned... I1, unsigned... I2>
  9. struct concat<seq<I1...>, seq<I2...>>
  10. : seq<I1..., (sizeof...(I1)+I2)...>{};
  11.  
  12. template<class S1, class S2>
  13. using Concat = Invoke<concat<S1, S2>>;
  14.  
  15. template<unsigned N> struct gen_seq;
  16. template<unsigned N> using GenSeq = Invoke<gen_seq<N>>;
  17.  
  18. template<unsigned N>
  19. struct gen_seq : Concat<GenSeq<N/2>, GenSeq<N - N/2>>{};
  20.  
  21. template<> struct gen_seq<0> : seq<>{};
  22. template<> struct gen_seq<1> : seq<0>{};
  23.  
  24. // example
  25.  
  26. template<unsigned... Is>
  27. void f(seq<Is...>);
  28.  
  29. int main(){
  30. f(gen_seq<6>());
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/kESqeF/ccylHU1G.o: In function `main':
prog.cpp:(.text.startup+0xe): undefined reference to `void f<0u, 1u, 2u, 3u, 4u, 5u>(seq<0u, 1u, 2u, 3u, 4u, 5u>)'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty