-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Greetings, I have the following code:
std::vector<Promise> promise_list = {
promise::resolve<float>(10),
promise::resolve<float>(11),
};
all(promise_list).then([](const std::vector<float> &vals){
/* code here for all promise objects are resolved */
}).fail([](){
/* code here for one of the promise objects is rejected */
});This compiles but bails with a bad any_cast execption. The following though works:
std::vector<Promise> promise_list = {
promise::resolve<float>(10),
promise::resolve<float>(11),
};
all(promise_list).then([](const std::vector<any> &vals){
std::vector<float> res{};
std::transform(vals.begin(), vals.end(), std::back_inserter(res),
[](const promise::any &r) { return r.cast<float>(); });
return res;
}).then([](const std::vector<float> &vals){
/* code here for all promise objects are resolved as floats */
}).fail([](){
/* code here for one of the promise objects is rejected */
});I am wondering if you can use the container std::vector<T>::value_type for the cast from the promise into the function. I am not sure if this would break other stuff though since it would need to happen after resolution. This would also break instances where you have multiple types returned by the promises. Thoughts?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels