diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-06-06 08:13:58 +0200 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-06-06 09:51:57 +0200 |
commit | 7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332 (patch) | |
tree | 3be2c22e9e1bc5199072734be2af03522d8204cb /src/core/hle | |
parent | HLE: Move SessionRequestHandler from Service:: to Kernel:: (diff) | |
download | yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.gz yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.bz2 yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.lz yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.xz yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.zst yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/result.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index c49650f7d..5f2cdbb96 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -416,6 +416,16 @@ ResultVal<T> MakeResult(Args&&... args) { } /** + * Deducible overload of MakeResult, allowing the template parameter to be ommited if you're just + * copy or move constructing. + */ +template <typename Arg> +ResultVal<std::remove_reference_t<Arg>> MakeResult(Arg&& arg) { + return ResultVal<std::remove_reference_t<Arg>>::WithCode(RESULT_SUCCESS, + std::forward<Arg>(arg)); +} + +/** * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps * the contained value and assigns it to `target`, which can be either an l-value expression or a * variable declaration. If it fails the return code is returned from the current function. Thus it @@ -426,3 +436,12 @@ ResultVal<T> MakeResult(Args&&... args) { if (CONCAT2(check_result_L, __LINE__).Failed()) \ return CONCAT2(check_result_L, __LINE__).Code(); \ target = std::move(*CONCAT2(check_result_L, __LINE__)) + +/** + * Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if + * non-success, or discarded otherwise. + */ +#define CASCADE_CODE(source) \ + auto CONCAT2(check_result_L, __LINE__) = source; \ + if (CONCAT2(check_result_L, __LINE__).IsError()) \ + return CONCAT2(check_result_L, __LINE__); |