AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Index.hpp
1#pragma once
2
3// std c++ headers
4#include <tuple>
5#include <type_traits>
6#include <utility>
7
8namespace AMDiS
9{
10 // introduce some shortcuts for integral constants
11 // ---------------------------------------------------------------------------
12
14 template <int I>
15 using int_t = std::integral_constant<int, I>;
16
18 template <int I>
19 constexpr int_t<I> int_ = {};
20
22 template <int... I>
23 using Ints = std::integer_sequence<int, I...>;
24
25 template <std::size_t I, int... J>
26 auto get(Ints<J...>) { return std::get<I>(std::make_tuple(int_<J>...)); }
27
28
30 template <std::size_t I>
31 using index_t = std::integral_constant<std::size_t, I>;
32
34 template <std::size_t I>
35 constexpr index_t<I> index_ = {};
36
37
39 template <std::size_t... I>
40 using Indices = std::index_sequence<I...>;
41
42 template <std::size_t I, std::size_t... J>
43 auto get(Indices<J...>) { return std::get<I>(std::make_tuple(index_<J>...)); }
44
45} // end namespace AMDiS