1 /* Copyright 2016 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/poly_collection for library home page.
9 #ifndef BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP
10 #define BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP
20 namespace poly_collection{
24 /* ripped from http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html */
26 template<typename T,T... Ints> struct integer_sequence{};
28 template<typename S> struct next_integer_sequence;
30 template<typename T,T... Ints>
31 struct next_integer_sequence<integer_sequence<T,Ints...>>
33 using type=integer_sequence<T,Ints...,sizeof...(Ints)>;
36 template<typename T,T I,T N> struct make_int_seq_impl;
38 template<typename T,T N>
39 using make_integer_sequence=typename make_int_seq_impl<T,0,N>::type;
41 template<typename T,T I,T N> struct make_int_seq_impl
43 using type=typename next_integer_sequence<
44 typename make_int_seq_impl<T,I+1,N>::type>::type;
47 template<typename T,T N> struct make_int_seq_impl<T,N,N>
49 using type=integer_sequence<T>;
52 template<std::size_t... Ints>
53 using index_sequence=integer_sequence<std::size_t,Ints...>;
55 template<std::size_t N>
56 using make_index_sequence=make_integer_sequence<std::size_t,N>;
58 } /* namespace poly_collection::detail */
60 } /* namespace poly_collection */
62 } /* namespace boost */