QResultStore::moveResult(): refuse to move from lvalues
The T&& result argument is deduced, therefore result is a Universal Reference and as such can bind to lvalues, not just rvalues. If passed an lvalue, the function would happily move away from it, which is not what the doctor prescribed. Catch the attempt with a static assertion. Pick-to: 6.5 Change-Id: Iff8c1abd5dcb1043ed94ba76570be5ba3d6f92da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
b2bcf3b68a
commit
10e106ae47
@ -149,6 +149,8 @@ public:
|
||||
template <typename T>
|
||||
int moveResult(int index, T &&result)
|
||||
{
|
||||
static_assert(!std::is_reference_v<T>, "trying to move from an lvalue!");
|
||||
|
||||
if (containsValidResultItem(index)) // reject if already present
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user