From a89e72929ed047344e221f65542e763e3f6ac3de Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Fri, 31 Jan 2025 00:30:08 +0100 Subject: Add try macro for status & status_or --- asl/status.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'asl/status.hpp') diff --git a/asl/status.hpp b/asl/status.hpp index 42695c3..169dfce 100644 --- a/asl/status.hpp +++ b/asl/status.hpp @@ -118,6 +118,8 @@ public: return {}; } + constexpr status&& throw_status() && { return ASL_MOVE(*this); } + friend void AslFormat(Formatter& f, const status&); template @@ -150,4 +152,6 @@ ASL_DEFINE_ERROR_(internal) ASL_DEFINE_ERROR_(runtime) ASL_DEFINE_ERROR_(invalid_argument) +#define ASL_TRY(VALUE) if (VALUE.ok()) {} else { return ASL_MOVE(VALUE).throw_status(); } + } // namespace asl -- cgit