-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
I wanted to know if there exists an API similar to value_or(...) that would allow me to do something like:
struct Something { int interesting{0}; };
int getter() {
QtPromise::QPromise<Something> promise = ...; // Obtained somehow
return promise.wait().value_or(Something{}).interesting;
}I often find myself doing something similar to:
int getter() {
QtPromise::QPromise<Something> promise = ...;
int outerInteresting = 0;
promise.then([&](const Something& s) { outerInteresting = s.interesting; }.wait();
return outerInteresting;
}Would an addition like value_or() be useful for the library?
Btw. I was also thinking that to_optional() could also fit my needs but that would require C++17 (and AFAIK the library aims to support C++11). What is the authors' current attitude towards conditional compilation and feature testing (if the compiler supports C++17)?
Metadata
Metadata
Assignees
Labels
No labels