OXYGENHUB
◆ main openmsx / src / utils / one_of.hh
433 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 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
	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
16
private:
17
	std::tuple<Ts...> tup;
18
};
19
20
#endif