Created
September 4, 2014 09:22
-
-
Save jamboree/04d9b0b0b22e91782717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<class A, class B> | |
struct P; | |
template<class... Ts> | |
struct L {}; | |
template<class T, class... Ts> | |
using mul = L<P<T, Ts>...>; | |
template<class...> | |
struct cat; | |
template<class T> | |
struct cat<T> | |
{ | |
using type = T; | |
}; | |
template<class... As, class... Bs> | |
struct cat<L<As...>, L<Bs...>> | |
{ | |
using type = L<As..., Bs...>; | |
}; | |
template<class A, class B, class... Ts> | |
struct cat<A, B, Ts...> | |
{ | |
using type = typename cat<typename cat<A, B>::type, Ts...>::type; | |
}; | |
template<class A, class B> | |
struct join; | |
template<class... As, class... Bs> | |
struct join<L<As...>, L<Bs...>> | |
{ | |
using type = typename cat<mul<As, Bs...>...>::type; | |
}; | |
template<class> | |
struct Print; | |
int main () | |
{ | |
Print<join<L<int[1], int[2]>, L<float[1], float[2], float[3]>>::type>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment