fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. #include <type_traits>
  4.  
  5. template<class...>
  6. struct type_list {};
  7.  
  8. template<class L, template<class> class F>
  9. struct map /* undefined */;
  10.  
  11. template<class... Contents, template<class> class F>
  12. struct map<type_list<Contents...>, F> {
  13. using type = type_list<typename F<Contents>::type...>;
  14. };
  15.  
  16. template<class L, template<class> class F>
  17. using map_t = typename map<L, F>::type;
  18.  
  19. template<class L1, class L2>
  20. struct concatenate /* undefined */;
  21.  
  22. template<class... Contents1, class... Contents2>
  23. struct concatenate<type_list<Contents1...>, type_list<Contents2...>> {
  24. using type = type_list<Contents1..., Contents2...>;
  25. };
  26.  
  27. template<class L1, class L2>
  28. using concatenate_t = typename concatenate<L1, L2>::type;
  29.  
  30. template<int Low, int High, class = void>
  31. struct range;
  32.  
  33. template<int Low, int High>
  34. using range_t = typename range<Low, High>::type;
  35.  
  36. template<int Low, int High, class>
  37. struct range {
  38. using type =
  39. concatenate_t<range_t<Low, (Low+High)/2>, range_t<(Low+High)/2, High>>;
  40. };
  41.  
  42. template<int Low>
  43. struct range<Low, Low, void> { using type = type_list<>; };
  44.  
  45. template<int Low, int High>
  46. struct range<Low, High, typename std::enable_if<High - Low == 1>::type> {
  47. using type = type_list<std::integral_constant<int, Low>>;
  48. };
  49.  
  50. template<int N>
  51. struct A {};
  52.  
  53. template<class N>
  54. struct make_A {
  55. using type = A<N::value>;
  56. };
  57.  
  58. using my_list_of_A = map_t<range_t<0, 16>, make_A>;
  59. int main() {
  60. std::cout << typeid(my_list_of_A).name() << std::endl;
  61. // you may pass that to c++filt
  62. return 0;
  63. }
Success #stdin #stdout 0s 4356KB
stdin
Standard input is empty
stdout
9type_listIJ1AILi0EES0_ILi1EES0_ILi2EES0_ILi3EES0_ILi4EES0_ILi5EES0_ILi6EES0_ILi7EES0_ILi8EES0_ILi9EES0_ILi10EES0_ILi11EES0_ILi12EES0_ILi13EES0_ILi14EES0_ILi15EEEE