From 05c58ef00263552d4925ed29ac0828cacdfc2ed1 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 1 Jun 2019 21:16:28 -0700 Subject: [PATCH] Add C++ only R_CATCH_MANY helper. --- include/stratosphere/results/utilities.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/stratosphere/results/utilities.h b/include/stratosphere/results/utilities.h index fcdca152..15a9972e 100644 --- a/include/stratosphere/results/utilities.h +++ b/include/stratosphere/results/utilities.h @@ -56,3 +56,19 @@ extern "C" { #ifdef __cplusplus } #endif + +// For C++, also define R_CATCH_MANY helper. +#ifdef __cplusplus + +template +constexpr inline bool _CheckResultsForMultiTryCatch(const Result &rc) { + static_assert((R_FAILED(rs) && ...), "Multi try catch result must be constexpr error Result!"); + return ((rs == rc) || ...); +} + +#define R_CATCH_MANY(...) \ + } else if (_CheckResultsForMultiTryCatch<__VA_ARGS__>(_tmp_r_try_catch_rc)) { \ + if (false) { } \ + else + +#endif