AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
TupleUtility.hpp
1#pragma once
2
3#include <tuple>
4#include <type_traits>
5#include <utility>
6
7#include <dune/common/hash.hh>
8
9namespace AMDiS
10{
11 namespace Impl
12 {
13 // Recursive template code derived from Matthieu M.
14 template <class Tuple, std::size_t I = std::tuple_size<Tuple>::value - 1>
15 struct HashTupleImpl
16 {
17 static void apply(size_t& seed, Tuple const& tuple)
18 {
19 HashTupleImpl<Tuple, I-1>::apply(seed, tuple);
20 Dune::hash_combine(seed, std::get<I>(tuple));
21 }
22 };
23
24 template <class Tuple>
25 struct HashTupleImpl<Tuple, 0>
26 {
27 static void apply(std::size_t& seed, Tuple const& tuple)
28 {
29 Dune::hash_combine(seed, std::get<0>(tuple));
30 }
31 };
32
33 } // end namespace Impl
34
35 template <class Tuple, template <class> class Map>
36 struct MapTuple;
37
38 template <class Tuple, template <class> class Map>
39 using MapTuple_t = typename MapTuple<Tuple,Map>::type;
40
41 template <class... T, template <class> class Map>
42 struct MapTuple<std::tuple<T...>, Map>
43 {
44 using type = std::tuple<Map<T>...>;
45 };
46
47 template <class Indices, template <std::size_t> class Map>
49
50 template <class Indices, template <std::size_t> class Map>
51 using IndexMapTuple_t = typename IndexMapTuple<Indices,Map>::type;
52
53 template <std::size_t... I, template <std::size_t> class Map>
54 struct IndexMapTuple<std::index_sequence<I...>, Map>
55 {
56 using type = std::tuple<Map<I>...>;
57 };
58
59} // end namespace AMDiS
Definition: TupleUtility.hpp:48
Definition: TupleUtility.hpp:36