diff options
Diffstat (limited to 'compat/meta.hpp')
-rw-r--r-- | compat/meta.hpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/compat/meta.hpp b/compat/meta.hpp index b1c1dd1a..900c515f 100644 --- a/compat/meta.hpp +++ b/compat/meta.hpp @@ -1,6 +1,8 @@ #pragma once +#include <type_traits> #include <tuple> +#include <cstddef> namespace meta { @@ -29,7 +31,20 @@ namespace detail { { using type = inst<xs...>; }; -} + + template<typename N, N max, N pos, typename... xs> + struct index_sequence_ + { + using part = std::integral_constant<N, pos>; + using type = typename index_sequence_<N, max, pos+1, xs..., part>::type; + }; + + template<typename N, N max, typename... xs> + struct index_sequence_<N, max, max, xs...> + { + using type = std::tuple<xs...>; + }; +} // ns detail template<typename... xs> @@ -50,4 +65,7 @@ using butlast = reverse<rest<reverse<xs...>>>; template<typename... xs> using last = lift<first, reverse<xs...>>; -} +template<std::size_t max> +using index_sequence = typename detail::index_sequence_<std::size_t, max, std::size_t(0)>::type; + +} // ns meta |