Alexandria  2.25.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
index_sequence.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef _ALEXANDRIAKERNEL_SEQUENCE_H
20 #define _ALEXANDRIAKERNEL_SEQUENCE_H
21 
22 #if __cplusplus > 201103L
23 #include <utility>
24 #endif
25 #include <cstddef>
26 
27 namespace Euclid {
28 
29 #if __cplusplus > 201103L
30 template <typename T, T... Idx>
31 using _integer_sequence = std::integer_sequence<T, Idx...>;
32 
33 template <std::size_t... Idx>
34 using _index_sequence = std::index_sequence<Idx...>;
35 
36 template <std::size_t N>
37 using _make_index_sequence = std::make_index_sequence<N>;
38 #else
39 #warning "Index sequences not available, using a custom implementation"
40 
41 template <typename T, T... Idx>
43  typedef T value_type;
44  static constexpr std::size_t size() noexcept {
45  return sizeof...(Idx);
46  }
47 };
48 
49 template <std::size_t... Idx>
51 
52 template <std::size_t N, std::size_t... Rest>
53 struct _index_sequence_helper : public _index_sequence_helper<N - 1, N - 1, Rest...> {};
54 
55 template <std::size_t... Rest>
56 struct _index_sequence_helper<0, Rest...> {
57  using type = _index_sequence<Rest...>;
58 };
59 
60 template <std::size_t N>
62 #endif
63 
64 } // namespace Euclid
65 
66 #endif // _ALEXANDRIAKERNEL_SEQUENCE_H
_integer_sequence< std::size_t, Idx...> _index_sequence
static constexpr std::size_t size() noexcept
constexpr std::size_t N
typename _index_sequence_helper< N >::type _make_index_sequence