diff options
Diffstat (limited to 'nihil.core/match.ccm')
| -rw-r--r-- | nihil.core/match.ccm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nihil.core/match.ccm b/nihil.core/match.ccm new file mode 100644 index 0000000..e1c894c --- /dev/null +++ b/nihil.core/match.ccm @@ -0,0 +1,18 @@ +// This source code is released into the public domain. +export module nihil.core:match; + +import nihil.std; + +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 |
