Details
-
User Story
-
Resolution: Done
-
P2: Important
-
6.0
-
None
-
21
-
Qt6_Foundation_ Sprint 6
-
9ba0715f08a64758453b941c4add22a269a30f71
Description
The function has the following signature now:
template<typename T> T QFutureInterface<T>::takeResult()
And somewhere in the function's body we have a code like this:
if (...) {
return {};
}
Which means that the type should be default-constructible. So, we have the following options:
- Add static assert (std::is_default_constructible_v<T>) at the beginning of this function.
- Return std::optional<T> instead of T.
The documentation should be extended in both cases.
I think that the second option is better because:
- This is not mandatory functional requirement for the type.
- You don't need to create a default constructed object.
- std::optional was designed for cases like this.
Perhaps, in the future, we could use std::expected or QExpected (once/if we have it implemented) to propagate an error message/code.
Attachments
Issue Links
- resulted in
-
QTBUG-117918 Debug builds with QFuture::waitForFinished and same-thread continuations may deadlock
-
- Closed
-
For Gerrit Dashboard: QTBUG-83389 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
296687,2 | QFutureInterface: takeResult() returns std::optional<T> | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
297018,2 | QFuture: the result type doesn't have to be a default-constructible | dev | qt/qtbase | Status: MERGED | +2 | 0 |