Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstring>
- namespace my_types
- {
- struct nil {};
- template <typename T, typename U>
- struct chain
- {
- typedef T first_type;
- typedef U second_type;
- };
- }
- template <template <typename, typename> class Chain, typename Nil>
- struct chain_generator
- {
- template <typename T, typename... Args>
- struct gen
- {
- private:
- template <size_t S = sizeof...(Args), typename Dummy = void>
- struct inner
- {
- typedef Chain<T, typename gen<Args...>::type > type;
- };
- template <typename Dummy>
- struct inner<0, Dummy>
- {
- typedef Chain<T, Nil> type;
- };
- public:
- typedef typename inner<sizeof...(Args)>::type type;
- };
- };
- int main( /* int argc, char* argv[] */ )
- {
- using my_types::chain;
- using my_types::nil;
- typedef chain<int, chain<float, chain<char, nil>>> t0;
- typedef chain_generator<chain, nil> my_gen;
- typedef my_gen::gen<int, float, char>::type t1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement