summaryrefslogtreecommitdiff
path: root/boost/poly_collection/detail/integer_sequence.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/poly_collection/detail/integer_sequence.hpp')
-rw-r--r--boost/poly_collection/detail/integer_sequence.hpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/boost/poly_collection/detail/integer_sequence.hpp b/boost/poly_collection/detail/integer_sequence.hpp
new file mode 100644
index 0000000000..d88e833f99
--- /dev/null
+++ b/boost/poly_collection/detail/integer_sequence.hpp
@@ -0,0 +1,64 @@
+/* Copyright 2016 Joaquin M Lopez Munoz.
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * See http://www.boost.org/libs/poly_collection for library home page.
+ */
+
+#ifndef BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP
+#define BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <cstddef>
+
+namespace boost{
+
+namespace poly_collection{
+
+namespace detail{
+
+/* ripped from http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html */
+
+template<typename T,T... Ints> struct integer_sequence{};
+
+template<typename S> struct next_integer_sequence;
+
+template<typename T,T... Ints>
+struct next_integer_sequence<integer_sequence<T,Ints...>>
+{
+ using type=integer_sequence<T,Ints...,sizeof...(Ints)>;
+};
+
+template<typename T,T I,T N> struct make_int_seq_impl;
+
+template<typename T,T N>
+using make_integer_sequence=typename make_int_seq_impl<T,0,N>::type;
+
+template<typename T,T I,T N> struct make_int_seq_impl
+{
+ using type=typename next_integer_sequence<
+ typename make_int_seq_impl<T,I+1,N>::type>::type;
+};
+
+template<typename T,T N> struct make_int_seq_impl<T,N,N>
+{
+ using type=integer_sequence<T>;
+};
+
+template<std::size_t... Ints>
+using index_sequence=integer_sequence<std::size_t,Ints...>;
+
+template<std::size_t N>
+using make_index_sequence=make_integer_sequence<std::size_t,N>;
+
+} /* namespace poly_collection::detail */
+
+} /* namespace poly_collection */
+
+} /* namespace boost */
+
+#endif