QResultStore: use unconditional move() in moveResult()
If the move can fail, so can most likely the copy. Use of move_if_noexcept() therefore trades a faster potentially-throwing operation for a slower potentially-throwing operation. It is true that a throwing move ctor may leave the source object in a partially-formed state while the copy ctor may not (exceptions prove the rule, hello auto_ptr), but we shouldn't pessimize lazy coders (missing noexcept) to cater for borderline-buggy code (throwing move ctor that doesn't provide the strong exception guarantee). Yes, you can construct such situations (and something as simple as std::array<std::pmr::string, 10> is already affected), but we don't cater for these anywhere else in Qt, so why do it here? Change-Id: I728af8e87ed86f24326530f704a48df1f728ac98 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
46e909a37a
commit
b2bcf3b68a
@ -152,7 +152,7 @@ public:
|
||||
if (containsValidResultItem(index)) // reject if already present
|
||||
return -1;
|
||||
|
||||
return addResult(index, static_cast<void *>(new T(std::move_if_noexcept(result))));
|
||||
return addResult(index, static_cast<void *>(new T(std::move(result))));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user