A standard function in C++ runs from start to finish and cannot be paused. A Coroutine is a generalized function that can suspend execution to yield control back to the caller, and later resume from the exact point of suspension with all local variables preserved.
co_yield expr;: Produces a value to the caller and pauses execution. Perfect for infinite number generators and streams.co_await expr;: Suspends execution until an asynchronous task (like a disk read or HTTP network request) finishes.co_return expr;: Returns a final value and terminates the coroutine frame.Boost your C++ proficiency by studying these closely connected core modules:
OS kernel threads vs cooperative stackless coroutines.
Combining ranges with coroutine generators.
Full feature list of modern standards.