Fix subtle SFINAE problem in QPromise::addResult

Accidentally found out that we enable/disable QPromise::addResult based
on type deduced from input argument, instead of using "value_type" of
QPromise itself, which is wrong

Simplified the checks to a single one -
EnableIfSameOrConvertible<InputType, StoredType> as this is sufficient
to account for both cases: QPromise<void> and QPromise<T> with input,
convertible to T

Change-Id: I657998c0e26241b0fc5e70988622984ece8871df
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
Andrei Golubev 2020-10-15 10:02:46 +02:00
parent 7332d3937d
commit db3d097db2

View File

@ -86,9 +86,7 @@ public:
// Core QPromise APIs
QFuture<T> future() const { return d.future(); }
template<typename U = T,
typename = QtPrivate::EnableForNonVoid<std::decay_t<U>>,
typename = QtPrivate::EnableIfSameOrConvertible<std::decay_t<U>, std::decay_t<T>>>
template<typename U, typename = QtPrivate::EnableIfSameOrConvertible<U, T>>
bool addResult(U &&result, int index = -1)
{
return d.reportResult(std::forward<U>(result), index);