From f1bc62bb4c962de530c22d2a1e73d33cdc85ea92 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 28 Aug 2018 09:39:47 -0400 Subject: hle/result: Make ResultVal's move constructor as noexcept Many containers within the standard library provide different behaviors based on whether or not a move constructor/assignment operator can be guaranteed not to throw or not. Notably, implementations will generally use std::move_if_noexcept (or an internal implementation of it) to provide strong exception guarantees. If a move constructor potentially throws (in other words, is not noexcept), then certain behaviors will create copies, rather than moving the values. For example, consider std::vector. When a std::vector calls resize(), there are two ways the elements can be relocated to the new block of memory (if a reallocation happens), by copy, or by moving the existing elements into the new block of memory. If a type does not have a guarantee that it will not throw in the move constructor, a copy will happen. However, if it can be guaranteed that the move constructor won't throw, then the elements will be moved. This just allows ResultVal to be moved instead of copied all the time if ever used in conjunction with containers for whatever reason. --- src/core/hle/result.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 3ebf7aadf..c6b18cfba 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -227,7 +227,7 @@ public: } } - ResultVal(ResultVal&& o) : result_code(o.result_code) { + ResultVal(ResultVal&& o) noexcept : result_code(o.result_code) { if (!o.empty()) { new (&object) T(std::move(o.object)); } -- cgit v1.2.3