From Jason Turner

[expr.yield]

Diff to HTML by rtfpessoa

tmp/tmp3c_b_bpt/{from.md → to.md} RENAMED
@@ -9,11 +9,11 @@ yield-expression:
9
  A *yield-expression* shall appear only within a suspension context of a
10
  function [[expr.await]]. Let *e* be the operand of the
11
  *yield-expression* and *p* be an lvalue naming the promise object of the
12
  enclosing coroutine [[dcl.fct.def.coroutine]], then the
13
  *yield-expression* is equivalent to the expression
14
- `co_await `*p*`.yield_value(`*e*`)`.
15
 
16
  [*Example 1*:
17
 
18
  ``` cpp
19
  template <typename T>
@@ -30,14 +30,14 @@ struct my_generator {
30
  iterator begin();
31
  iterator end();
32
  };
33
 
34
  my_generator<pair<int,int>> g1() {
35
- for (int i = i; i < 10; ++i) co_yield {i,i};
36
  }
37
  my_generator<pair<int,int>> g2() {
38
- for (int i = i; i < 10; ++i) co_yield make_pair(i,i);
39
  }
40
 
41
  auto f(int x = co_yield 5); // error: yield-expression outside of function suspension context
42
  int a[] = { co_yield 1 }; // error: yield-expression outside of function suspension context
43
 
 
9
  A *yield-expression* shall appear only within a suspension context of a
10
  function [[expr.await]]. Let *e* be the operand of the
11
  *yield-expression* and *p* be an lvalue naming the promise object of the
12
  enclosing coroutine [[dcl.fct.def.coroutine]], then the
13
  *yield-expression* is equivalent to the expression
14
+ `co_await p.yield_value(e)`.
15
 
16
  [*Example 1*:
17
 
18
  ``` cpp
19
  template <typename T>
 
30
  iterator begin();
31
  iterator end();
32
  };
33
 
34
  my_generator<pair<int,int>> g1() {
35
+ for (int i = 0; i < 10; ++i) co_yield {i,i};
36
  }
37
  my_generator<pair<int,int>> g2() {
38
+ for (int i = 0; i < 10; ++i) co_yield make_pair(i,i);
39
  }
40
 
41
  auto f(int x = co_yield 5); // error: yield-expression outside of function suspension context
42
  int a[] = { co_yield 1 }; // error: yield-expression outside of function suspension context
43