summaryrefslogtreecommitdiffhomepage
path: root/compat/meta.hpp
diff options
context:
space:
mode:
authorStanisław Halik <sthalik@misaki.pl>2017-05-14 16:22:09 +0200
committerGitHub <noreply@github.com>2017-05-14 16:22:09 +0200
commit5c23666b58bb1dd4aea15c0d62a2f716d5be7f52 (patch)
treee6497e9b55c073be209ec673ef05e62bf57a2c8f /compat/meta.hpp
parent4701dd3b0c8323a11cf7d5ad09c579a9864a41bd (diff)
parentc392181211b245e74292424500265323c960c1aa (diff)
Merge branch 'unstable' into unstable
Diffstat (limited to 'compat/meta.hpp')
-rw-r--r--compat/meta.hpp22
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