I think coroutine / goroutine is very useful if many simultaneous small tasks should be done quickly. The current std::threadcannot meet the requirements due to its high cost.
I also think that coroutine / goroutine cannot be supported simply through the C ++ library, it should be implemented directly using the basic functions of the language. Since coroutine / goroutine has special semantics that do not have a corresponding concept in the current C ++ standard.
When adding a new keyword cppgo, we can write the code as follows:
void f(int n)
{
...
}
int main()
{
for (int i = 0; i < 10000; ++i)
{
cppgo f(i);
}
}
How cool it would be!
Does the C ++ 1y standard support coroutine / goroutine coroutine?