Stax
Programming language
Loading...
Searching...
No Matches
variant.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <variant>
4
5namespace stax {
6
20template <class... Ts>
21struct VariantSwitch : Ts... {
22 using Ts::operator()...;
23};
24template <class... Ts>
25VariantSwitch(Ts...) -> VariantSwitch<Ts...>;
26
27} // namespace stax
28
29template <typename T, class... Types>
30inline bool operator==(const T& t, const std::variant<Types...>& v) {
31 const T* c = std::get_if<T>(&v);
32
33 return c && *c == t; // true if v contains a T that compares equal to t
34}
35
36template <typename T, class... Types>
37inline bool operator==(const std::variant<Types...>& v, const T& t) {
38 return t == v;
39}
Definition lexer.cpp:8