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
6template<typename... Ts>
7class one_of {
8public:
9 explicit constexpr one_of(Ts... ts) : tup(ts...) {}
10
11 template<typename T> // abbreviated syntax triggered ICE in msvc?
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
16private:
17 std::tuple<Ts...> tup;
18};
19
20#endif
TclObject t
constexpr one_of(Ts... ts)
Definition one_of.hh:9
friend constexpr bool operator==(const T &t, const one_of &o)
Definition one_of.hh:12