Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
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
27namespace Euclid {
28
29#if __cplusplus > 201103L
30template <typename T, T... Idx>
32
33template <std::size_t... Idx>
34using _index_sequence = std::index_sequence<Idx...>;
35
36template <std::size_t N>
37using _make_index_sequence = std::make_index_sequence<N>;
38#else
39#warning "Index sequences not available, using a custom implementation"
40
41template <typename T, T... Idx>
43 typedef T value_type;
44 static constexpr std::size_t size() noexcept {
45 return sizeof...(Idx);
46 }
47};
48
49template <std::size_t... Idx>
51
52template <std::size_t N, std::size_t... Rest>
53struct _index_sequence_helper : public _index_sequence_helper<N - 1, N - 1, Rest...> {};
54
55template <std::size_t... Rest>
56struct _index_sequence_helper<0, Rest...> {
57 using type = _index_sequence<Rest...>;
58};
59
60template <std::size_t N>
62#endif
63
64} // namespace Euclid
65
66#endif // _ALEXANDRIAKERNEL_SEQUENCE_H
typename _index_sequence_helper< N >::type _make_index_sequence
static constexpr std::size_t size() noexcept