3 ms·
The concepts part I'm not sure about, but the other parts don't look so bad. According to cppreference.com[0]: > Coroutines cannot use variadic arguments, plai
by nemetroid 7y ago
The concepts part I'm not sure about, but the other parts don't look so bad. According to cppreference.com[0]:
> Coroutines cannot use variadic arguments, plain return statements, or placeholder return types (auto or Concept).
> variadic arguments
For the purposes of creating variadic functions, variadic templates are the preferred solution, since variadic arguments have a number of drawbacks (e.g. unavoidable type promotions).
> plain return statements
This is the definition of C++ coroutines, more or less.
> placeholder return types (auto or Concept)
Note that this isn't the typical use of auto (i.e. inferring the type from the right hand side of an assignment), but about return type deduction. From a quick read, it looks like there are multiple, equally valid kind of coroutines (e.g. lazy<int> vs generator<int>) which cannot be deduced from the body of the coroutine. It could be argued that lazy<auto> should work, but I would guess it clashes with all the already existing complexity of template deduction. I agree that this looks like a wart but not a horrible one.
I'm not sure about the concept part, would have to learn more about concepts to comment.
> Constexpr functions, constructors, destructors, and the main function cannot be coroutines.
> Constexpr functions
Constexpr functions are functions whose value can be decided at compile time. Coroutines can call constexpr functions, they just can't be one. I guess it could be useful to determine the full output sequence of a coroutine at compile time. Maybe it could be added in a future language version, if it's worth the added complexity.
> constructors, destructors, and the main function cannot be coroutines
I guess this is just formalism, having those things as coroutines doesn't make logical sense.
0: https://en.cppreference.com/w/cpp/language/coroutines https://en.cppreference.com/w/cpp/language/coroutines
- gigatexal 7y agoThanks for the itemized reply. Your points make sense