Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Определение списка целых чисел времени компиляции IntList
- template <int ... Ints>
- struct IntList;
- template <int H, int ... I>
- struct IntList <H, I...>
- {
- static int const Head = H;
- using Tail = IntList<I...>;
- };
- template <>
- struct IntList <> {};
- template <typename IL>
- struct IntLength
- {
- static int const value = 1 + IntLength <typename IL::Tail>::value;
- };
- template <>
- struct IntLength <IntList<>>
- {
- static int const value = 0;
- };
- // добавление элемента в начало списка
- template<int H, typename IL>
- struct IntCons;
- template<int H, int... Ints>
- struct IntCons<H, IntList<Ints...>>
- {
- using type = IntList<H, Ints...>;
- };
- // добавление элемента в конец списка
- template<typename IL, int N>
- struct IntAdd;
- template<int... Ints, int N>
- struct IntAdd<IntList<Ints...>, N>
- {
- using type = IntList<Ints..., N>;
- };
- template <int N, typename IL = IntList<>>
- struct Generate;
- template <int N, int... Ints>
- struct Generate <N, IntList<Ints...>>
- {
- using type = typename IntAdd<typename Generate<N - 1, IntList<>>::type, N - 1>::type;
- };
- template<>
- struct Generate<0>
- {
- static const int length = 0;
- using type = IntList<>;
- };
- template<typename IL1, typename IL2>
- struct Zip;
- template<typename... Ints1, typename... Ints2>
- struct Zip<IntList<Ints1...>, IntList<Ints2...>>
- {
- using type = IntList<Ints1..., Ints2...>;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement