From 06fafff8e9e9c096cc39bde0306caa53ad3a2351 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Wed, 2 Jul 2025 03:43:39 +0100 Subject: move error and match to util --- nihil.util/match.ccm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 nihil.util/match.ccm (limited to 'nihil.util/match.ccm') diff --git a/nihil.util/match.ccm b/nihil.util/match.ccm new file mode 100644 index 0000000..b72416a --- /dev/null +++ b/nihil.util/match.ccm @@ -0,0 +1,18 @@ +// This source code is released into the public domain. +export module nihil.util:match; + +import nihil.std; + +namespace nihil { + +export template +struct match : Ts... { using Ts::operator()...; }; + +export template +[[nodiscard]] constexpr decltype(auto) operator| + (std::variant const &v, match const &match) +{ + return std::visit(match, v); +} + +} // namespace nihil -- cgit v1.2.3