diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-31 00:30:08 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-31 00:30:08 +0100 |
commit | a89e72929ed047344e221f65542e763e3f6ac3de (patch) | |
tree | ca36c931c8b23a766c89f4e2fb7822afcace3866 /asl/status.hpp | |
parent | 224048d0f4022f91c2074daddf9dcafbf11f2be9 (diff) |
Add try macro for status & status_or
Diffstat (limited to 'asl/status.hpp')
-rw-r--r-- | asl/status.hpp | 4 |
1 files changed, 4 insertions, 0 deletions
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<typename H> @@ -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 |