Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _SEQUENCE_GENERATOR_H
- #define _SEQUENCE_GENERATOR_H
- /*
- // Usage
- template<int ...S, typename ...T>
- void Print(seq<S...> const &, std::tuple<T...> const & t)
- {
- using expander = int[]; expander{(std::cout.operator<<(std::get<S>(t)), 0)...};
- std::cout << std::endl;
- }
- template<typename ...T>
- void Print(std::tuple<T...>const& t)
- {
- static typename gens<sizeof...(T)>::type idx;
- Print(idx, t);
- }
- Print(std::make_tuple(123));
- */
- template<int ...>
- struct seq { };
- template<int N, int ...S>
- struct gens : gens<N - 1, N - 1, S...> { };
- template<int ...S>
- struct gens<0, S...> {
- typedef seq<S...> type;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement