keymap.h
Go to the documentation of this file.
1 #ifndef TTG_BASE_KEYMAP_H
2 #define TTG_BASE_KEYMAP_H
3 
4 #include <type_traits>
5 #include "ttg/util/meta.h"
6 #include "ttg/util/hash.h"
7 
8 namespace ttg {
9  namespace detail {
10 
14  template <typename keyT, typename Enabler = void>
16  template <typename keyT>
18  keyT, std::enable_if_t<meta::has_ttg_hash_specialization_v<keyT> || meta::is_void_v<keyT>>> {
19  default_keymap_impl() = default;
20  default_keymap_impl(int world_size) : world_size(world_size) {}
21 
22  template <typename Key = keyT>
23  std::enable_if_t<!meta::is_void_v<Key>,int>
24  operator()(const Key &key) const {
25  if (world_size == 1) {
26  return 0;
27  } else {
28  return ttg::hash<keyT>{}(key) % world_size;
29  }
30  }
31  template <typename Key = keyT>
32  std::enable_if_t<meta::is_void_v<Key>,int>
33  operator()() const { return 0; }
34 
35  private:
36  int world_size;
37  };
38 
39 
41  template <typename keyT>
43  default_priomap_impl() = default;
44 
45  template <typename Key = keyT>
46  std::enable_if_t<!meta::is_void_v<Key>,int>
47  operator()(const Key &key) const { return 0; }
48  template <typename Key = keyT>
49  std::enable_if_t<meta::is_void_v<Key>,int>
50  operator()() const { return 0; }
51  };
52 
53  } // namespace detail
54 
55 } // namespace ttg
56 
57 #endif // TTG_BASE_KEYMAP_H
top-level TTG namespace contains runtime-neutral functionality
Definition: keymap.h:8
the default priority map implementation
Definition: keymap.h:42
std::enable_if_t<!meta::is_void_v< Key >, int > operator()(const Key &key) const
Definition: keymap.h:47
std::enable_if_t< meta::is_void_v< Key >, int > operator()() const
Definition: keymap.h:50
Computes hash values for objects of type T.
Definition: hash.h:81