Conditionally choose return value or error #1940
Unanswered
BartolomeyKant
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure if this topic was discussed anywhere, but I can't find the solution.
let's have this snippet
As you may notice I'm trying to return different senders depend on val. And it's not compile.
So the question is how in runtime choose
set_valueorset_error?The obvious solution is just make the new
Senderwith logic on itsop_state::start. But it's a lot of boilerplate code for each case there I need it.libunifexhas genericcreatesender. Why don't we have same instdexec?Or maybe there something like:
{ if (val %2 == 0) { return just<set_value_t(int), set_error_t(int)>::set_value(v); } else { return just<set_value_t(int), set_error_t(int)>::set_error(v); } }?
How do you usually solve such task?
Beta Was this translation helpful? Give feedback.
All reactions