]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
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) | |
5 | * | |
6 | * See http://www.boost.org/libs/poly_collection for library home page. | |
7 | */ | |
8 | ||
9 | #ifndef BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP | |
10 | #define BOOST_POLY_COLLECTION_DETAIL_INTEGER_SEQUENCE_HPP | |
11 | ||
12 | #if defined(_MSC_VER) | |
13 | #pragma once | |
14 | #endif | |
15 | ||
16 | #include <cstddef> | |
17 | ||
18 | namespace boost{ | |
19 | ||
20 | namespace poly_collection{ | |
21 | ||
22 | namespace detail{ | |
23 | ||
24 | /* ripped from http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html */ | |
25 | ||
26 | template<typename T,T... Ints> struct integer_sequence{}; | |
27 | ||
28 | template<typename S> struct next_integer_sequence; | |
29 | ||
30 | template<typename T,T... Ints> | |
31 | struct next_integer_sequence<integer_sequence<T,Ints...>> | |
32 | { | |
33 | using type=integer_sequence<T,Ints...,sizeof...(Ints)>; | |
34 | }; | |
35 | ||
36 | template<typename T,T I,T N> struct make_int_seq_impl; | |
37 | ||
38 | template<typename T,T N> | |
39 | using make_integer_sequence=typename make_int_seq_impl<T,0,N>::type; | |
40 | ||
41 | template<typename T,T I,T N> struct make_int_seq_impl | |
42 | { | |
43 | using type=typename next_integer_sequence< | |
44 | typename make_int_seq_impl<T,I+1,N>::type>::type; | |
45 | }; | |
46 | ||
47 | template<typename T,T N> struct make_int_seq_impl<T,N,N> | |
48 | { | |
49 | using type=integer_sequence<T>; | |
50 | }; | |
51 | ||
52 | template<std::size_t... Ints> | |
53 | using index_sequence=integer_sequence<std::size_t,Ints...>; | |
54 | ||
55 | template<std::size_t N> | |
56 | using make_index_sequence=make_integer_sequence<std::size_t,N>; | |
57 | ||
58 | } /* namespace poly_collection::detail */ | |
59 | ||
60 | } /* namespace poly_collection */ | |
61 | ||
62 | } /* namespace boost */ | |
63 | ||
64 | #endif |