openMSX
one_of.hh
Go to the documentation of this file.
1 #ifndef ONE_OF_HH
2 #define ONE_OF_HH
3 
4 #include <tuple>
5 
6 template<typename... Ts>
7 class one_of {
8 public:
9  constexpr one_of(Ts... ts) : tup(ts...) {}
10 
11  template<typename T>
12  friend constexpr bool operator==(const T& t, const one_of& o) {
13  return std::apply([&](const Ts& ... ts) { return (... || (t == ts)); }, o.tup);
14  }
15 
16  template<typename T>
17  friend constexpr bool operator!=(const T& t, const one_of& o) {
18  return !(t == o);
19  }
20 
21 private:
22  std::tuple<Ts...> tup;
23 };
24 
25 #endif
one_of::operator==
constexpr friend bool operator==(const T &t, const one_of &o)
Definition: one_of.hh:12
t
TclObject t
Definition: TclObject_test.cc:264
one_of::operator!=
constexpr friend bool operator!=(const T &t, const one_of &o)
Definition: one_of.hh:17
one_of
Definition: one_of.hh:7
one_of::one_of
constexpr one_of(Ts... ts)
Definition: one_of.hh:9