seq.hpp 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef BOOST_HOF_GUARD_FUNCTION_DETAIL_SEQ_H
  8. #define BOOST_HOF_GUARD_FUNCTION_DETAIL_SEQ_H
  9. #include <cstdlib>
  10. namespace boost { namespace hof {
  11. namespace detail {
  12. template<std::size_t ...>
  13. struct seq
  14. {
  15. typedef seq type;
  16. };
  17. template <class, class>
  18. struct merge_seq;
  19. template <size_t... Xs, size_t... Ys>
  20. struct merge_seq<seq<Xs...>, seq<Ys...>>
  21. : seq<Xs..., (sizeof...(Xs)+Ys)...>
  22. {};
  23. template<std::size_t N>
  24. struct gens
  25. : merge_seq<
  26. typename gens<N/2>::type,
  27. typename gens<N - N/2>::type
  28. >
  29. {};
  30. template<> struct gens<0> : seq<> {};
  31. template<> struct gens<1> : seq<0> {};
  32. }
  33. }} // namespace boost::hof
  34. #endif