| 1 | /*============================================================================= |
| 2 | Copyright (c) 2012 Paul Fultz II |
| 3 | seq.h |
| 4 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | ==============================================================================*/ |
| 7 | |
| 8 | #ifndef BOOST_HOF_GUARD_FUNCTION_DETAIL_SEQ_H |
| 9 | #define BOOST_HOF_GUARD_FUNCTION_DETAIL_SEQ_H |
| 10 | |
| 11 | #include <cstdlib> |
| 12 | |
| 13 | namespace boost { namespace hof { |
| 14 | |
| 15 | namespace detail { |
| 16 | |
| 17 | template<std::size_t ...> |
| 18 | struct seq |
| 19 | { |
| 20 | typedef seq type; |
| 21 | }; |
| 22 | |
| 23 | template <class, class> |
| 24 | struct merge_seq; |
| 25 | |
| 26 | template <size_t... Xs, size_t... Ys> |
| 27 | struct merge_seq<seq<Xs...>, seq<Ys...>> |
| 28 | : seq<Xs..., (sizeof...(Xs)+Ys)...> |
| 29 | {}; |
| 30 | |
| 31 | template<std::size_t N> |
| 32 | struct gens |
| 33 | : merge_seq< |
| 34 | typename gens<N/2>::type, |
| 35 | typename gens<N - N/2>::type |
| 36 | > |
| 37 | {}; |
| 38 | |
| 39 | template<> struct gens<0> : seq<> {}; |
| 40 | template<> struct gens<1> : seq<0> {}; |
| 41 | |
| 42 | |
| 43 | } |
| 44 | }} // namespace boost::hof |
| 45 | |
| 46 | #endif |
| 47 | |