blob: d67bd0ba9f5f5c8fd6a49ecdd83298b719bd9f3e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/*
* This source code is released into the public domain.
*/
module;
#include <variant>
export module nihil.match;
namespace nihil {
export template<class... Ts>
struct match : Ts... { using Ts::operator()...; };
export template<typename... Ts, typename... Fs>
[[nodiscard]] constexpr decltype(auto) operator|
(std::variant<Ts...> const &v, match<Fs...> const &match)
{
return std::visit(match, v);
}
} // namespace nihil
|