void.h
Go to the documentation of this file.
1 #ifndef TTG_VOID_H
2 #define TTG_VOID_H
3 #include <iostream>
4 #include "ttg/util/meta.h"
5 
6 namespace ttg {
8 
11  class Void {
12  public:
13  Void() = default;
14  template <typename T> explicit Void(T&&) {}
15  };
16 
17  inline bool operator==(const Void&, const Void&) { return true; }
18  inline bool operator!=(const Void&, const Void&) { return false; }
19 
20  inline std::ostream& operator<<(std::ostream& os, const ttg::Void&) {
21  return os;
22  }
23 
24  static_assert(meta::is_empty_tuple_v<std::tuple<>>,"ouch");
25  static_assert(meta::is_empty_tuple_v<std::tuple<Void>>,"ouch");
26 
27  namespace detail {
28 
29  template<std::size_t... Is>
30  auto make_void_tuple(std::index_sequence<Is...>) {
31  auto g = [](int i){ return Void{}; };
32  return std::make_tuple(g(Is)...);
33  }
34 
35  template<std::size_t N>
36  auto make_void_tuple() {
37  return make_void_tuple(std::make_index_sequence<N>{});
38  }
39 
40  } // namespace detail
41 
42 } // namespace ttg
43 
44 namespace std {
45  template <>
46  struct hash<ttg::Void> {
47  template <typename ... Args> int64_t operator()(Args&& ... args) const { return 0; }
48  };
49 } // namespace std
50 
51 #endif // TTG_VOID_H
A complete version of void.
Definition: void.h:11
Void()=default
Void(T &&)
Definition: void.h:14
auto make_void_tuple(std::index_sequence< Is... >)
Definition: void.h:30
top-level TTG namespace contains runtime-neutral functionality
Definition: keymap.h:8
bool operator==(const Void &, const Void &)
Definition: void.h:17
std::ostream & operator<<(std::ostream &os, const MultiIndex< Rank > &key)
Definition: multiindex.h:83
bool operator!=(const Void &, const Void &)
Definition: void.h:18
int64_t operator()(Args &&... args) const
Definition: void.h:47