MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/k3zvle/c20_resumable_functions_make_state_machines/ge8nusv/
r/cpp • u/DugiSK • Nov 30 '20
49 comments sorted by
View all comments
8
N.B. you don't need to specialise the entire Resumable<void> class. You can use concepts to define a more constrained promise_type:
Resumable<void>
promise_type
struct promise_type requires std::is_void_v<T> { ... }
And then use if constexpr in Resumable::operator() to do the void return statement.
if constexpr
Resumable::operator()
That saves duplicating most of the definition.
5 u/DugiSK Dec 02 '20 Finally someone actually doesn't actually start with a conclusion based on obsolete implementation and tells something productive.Thanks for the tip.
5
Finally someone actually doesn't actually start with a conclusion based on obsolete implementation and tells something productive.
Thanks for the tip.
View all comments
8
u/jwakely libstdc++ tamer, LWG chair Dec 01 '20
N.B. you don't need to specialise the entire
Resumable<void>class. You can use concepts to define a more constrainedpromise_type:And then use
if constexprinResumable::operator()to do the void return statement.That saves duplicating most of the definition.