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> // abbreviated syntax triggered ICE in msvs?
12  [[nodiscard]] 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 private:
17  std::tuple<Ts...> tup;
18 };
19 
20 #endif
TclObject t
Definition: one_of.hh:7
constexpr friend bool operator==(const T &t, const one_of &o)
Definition: one_of.hh:12
constexpr one_of(Ts... ts)
Definition: one_of.hh:9