Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // тип IntList уже определён
  2.  
  3. // реализация метафункции IntCons
  4.  
  5. template<int Head, typename T>
  6. struct IntCons;
  7.  
  8. template<int Head, int ... Ints>
  9. struct IntCons<Head, IntList<Ints...>>
  10. {
  11. using type = IntList<Head, Ints...>;
  12. };
  13.  
  14.  
  15. template<int Head>
  16. struct IntCons<Head,IntList<>>
  17. {
  18. using type = IntList<Head>;
  19. };
  20.  
  21.  
  22. // реализация метафункции Generate
  23.  
  24.  
  25. template <int, int = 0 >
  26. struct Generate;
  27.  
  28. template< int Value, int IL >
  29. struct Generate
  30. {
  31. using type = typename IntCons<IL, typename Generate< Value - 1, IL+1 >::type >::type;
  32. };
  33.  
  34. template<int IL>
  35. struct Generate<0, IL>
  36. {
  37. using type = IntList<>;
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement