TupleUtility.hpp 762 Bytes
Newer Older
1
2
3
4
#pragma once

#include <tuple>
#include <type_traits>
5
#include <utility>
6

7
8
#include <dune/common/hash.hh>

9
namespace AMDiS
10
{
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  namespace Impl
  {
    // Recursive template code derived from Matthieu M.
    template <class Tuple, std::size_t I = std::tuple_size<Tuple>::value - 1>
    struct HashTupleImpl
    {
      static void apply(size_t& seed, Tuple const& tuple)
      {
        HashTupleImpl<Tuple, I-1>::apply(seed, tuple);
        Dune::hash_combine(seed, std::get<I>(tuple));
      }
    };

    template <class Tuple>
    struct HashTupleImpl<Tuple, 0>
    {
      static void apply(std::size_t& seed, Tuple const& tuple)
      {
        Dune::hash_combine(seed, std::get<0>(tuple));
      }
    };

  } // end namespace Impl

35
} // end namespace AMDiS