Skip to content

Commit 452a63b

Browse files
Move note about using cppcoro to the top of the coroutines section.
1 parent 3ca9ac1 commit 452a63b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CPP20.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ C++20 includes the following new library features:
3838
## C++20 Language Features
3939

4040
### Coroutines
41+
42+
> **Note:** While these examples illustrate how to use coroutines at a basic level, there is lots more going on when the code is compiled. These examples are not meant to be complete coverage of C++20's coroutines. Since the `generator` and `task` classes are not provided by the standard library yet, I used the cppcoro library to compile these examples.
43+
4144
_Coroutines_ are special functions that can have their execution suspended and resumed. To define a coroutine, the `co_return`, `co_await`, or `co_yield` keywords must be present in the function's body. C++20's coroutines are stackless; unless optimized out by the compiler, their state is allocated on the heap.
4245

4346
An example of a coroutine is a _generator_ function, which yields (i.e. generates) a value at each invocation:
@@ -83,8 +86,6 @@ auto meaning_of_life = calculate_meaning_of_life();
8386
co_await meaning_of_life; // == 42
8487
```
8588

86-
**Note:** While these examples illustrate how to use coroutines at a basic level, there is lots more going on when the code is compiled. These examples are not meant to be complete coverage of C++20's coroutines. Since the `generator` and `task` classes are not provided by the standard library yet, I used the cppcoro library to compile these examples.
87-
8889
### Concepts
8990
_Concepts_ are named compile-time predicates which constrain types. They take the following form:
9091
```

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ C++11 includes the following new library features:
141141
## C++20 Language Features
142142

143143
### Coroutines
144+
145+
> **Note:** While these examples illustrate how to use coroutines at a basic level, there is lots more going on when the code is compiled. These examples are not meant to be complete coverage of C++20's coroutines. Since the `generator` and `task` classes are not provided by the standard library yet, I used the cppcoro library to compile these examples.
146+
144147
_Coroutines_ are special functions that can have their execution suspended and resumed. To define a coroutine, the `co_return`, `co_await`, or `co_yield` keywords must be present in the function's body. C++20's coroutines are stackless; unless optimized out by the compiler, their state is allocated on the heap.
145148

146149
An example of a coroutine is a _generator_ function, which yields (i.e. generates) a value at each invocation:
@@ -186,8 +189,6 @@ auto meaning_of_life = calculate_meaning_of_life();
186189
co_await meaning_of_life; // == 42
187190
```
188191

189-
**Note:** While these examples illustrate how to use coroutines at a basic level, there is lots more going on when the code is compiled. These examples are not meant to be complete coverage of C++20's coroutines. Since the `generator` and `task` classes are not provided by the standard library yet, I used the cppcoro library to compile these examples.
190-
191192
### Concepts
192193
_Concepts_ are named compile-time predicates which constrain types. They take the following form:
193194
```

0 commit comments

Comments
 (0)