QResultStore: add emplaceResult<T>()
... use it in moveResult(). Task-number: QTBUG-112270 Change-Id: I1233a710801d73c9153439b74a7a3900d2d9e39d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
02e2682ee8
commit
3087aa55dc
@ -134,6 +134,14 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename T, typename...Args>
|
||||
int emplaceResult(int index, Args&&...args)
|
||||
{
|
||||
if (containsValidResultItem(index)) // reject if already present
|
||||
return -1;
|
||||
return addResult(index, static_cast<void *>(new T(std::forward<Args>(args)...)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int addResult(int index, const T *result)
|
||||
{
|
||||
@ -151,10 +159,7 @@ public:
|
||||
{
|
||||
static_assert(!std::is_reference_v<T>, "trying to move from an lvalue!");
|
||||
|
||||
if (containsValidResultItem(index)) // reject if already present
|
||||
return -1;
|
||||
|
||||
return addResult(index, static_cast<void *>(new T(std::move(result))));
|
||||
return emplaceResult<std::remove_cv_t<T>>(index, std::forward<T>(result));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user