1
+ namespace std {
2
+
3
+ template <class R , class ... Args>
4
+ struct coroutine_traits {
5
+ using promise_type = R::promise_type;
6
+ };
7
+
8
+ using nullptr_t = decltype (nullptr );
9
+
10
+ template <typename Promise>
11
+ struct coroutine_handle {
12
+ constexpr coroutine_handle () noexcept ;
13
+ constexpr coroutine_handle ( std::nullptr_t ) noexcept ;
14
+ coroutine_handle (const coroutine_handle&) noexcept ;
15
+ coroutine_handle (coroutine_handle&&) noexcept ;
16
+
17
+ static coroutine_handle from_promise (Promise&);
18
+ coroutine_handle& operator =(nullptr_t ) noexcept ;
19
+ coroutine_handle& operator =(const coroutine_handle&) noexcept ;
20
+ coroutine_handle& operator =(coroutine_handle&&) noexcept ;
21
+ constexpr operator coroutine_handle () const noexcept ;
22
+
23
+ bool done () const ;
24
+ constexpr explicit operator bool () const noexcept ;
25
+
26
+ void operator ()() const ;
27
+ void resume () const ;
28
+
29
+ void destroy () const ;
30
+
31
+ Promise& promise () const ;
32
+
33
+ constexpr void * address () const noexcept ;
34
+ static constexpr coroutine_handle from_address (void *);
35
+ };
36
+
37
+ template <typename Promise>
38
+ constexpr bool operator ==(coroutine_handle<Promise>, coroutine_handle<Promise>) noexcept ;
39
+
40
+ struct suspend_always {
41
+ constexpr bool await_ready () const noexcept ;
42
+ template <typename Promise> constexpr void await_suspend (coroutine_handle<Promise>) const noexcept ;
43
+ constexpr void await_resume () const noexcept ;
44
+ };
45
+ }
46
+
47
+ class co_returnable_void {
48
+ public:
49
+ struct promise_type ;
50
+ co_returnable_void (std::coroutine_handle<promise_type>);
51
+
52
+ co_returnable_void (co_returnable_void&) = delete ;
53
+ co_returnable_void (co_returnable_void&&) = delete ;
54
+ };
55
+
56
+ struct co_returnable_void ::promise_type {
57
+ std::coroutine_handle<promise_type> get_return_object ();
58
+ std::suspend_always initial_suspend () noexcept ;
59
+ std::suspend_always final_suspend () noexcept ;
60
+
61
+ void return_void ();
62
+ void unhandled_exception ();
63
+
64
+ std::suspend_always yield_value (int );
65
+ };
66
+
67
+ class co_returnable_value {
68
+ public:
69
+ struct promise_type ;
70
+ co_returnable_value (std::coroutine_handle<promise_type>);
71
+
72
+ co_returnable_value (co_returnable_value&) = delete ;
73
+ co_returnable_value (co_returnable_value&&) = delete ;
74
+ };
75
+
76
+ struct co_returnable_value ::promise_type {
77
+ std::coroutine_handle<promise_type> get_return_object ();
78
+ std::suspend_always initial_suspend () noexcept ;
79
+ std::suspend_always final_suspend () noexcept ;
80
+
81
+ void return_value (int );
82
+ void unhandled_exception ();
83
+
84
+ std::suspend_always yield_value (int );
85
+ };
86
+
87
+ co_returnable_void co_return_void () {
88
+ co_return ;
89
+ }
90
+
91
+ co_returnable_value co_return_int (int i) {
92
+ co_return i;
93
+ }
94
+
95
+ co_returnable_void co_yield_value_void (int i) {
96
+ co_yield i;
97
+ }
98
+
99
+ co_returnable_value co_yield_value_value (int i) {
100
+ co_yield i;
101
+ }
102
+
103
+ co_returnable_void co_yield_and_return_void (int i) {
104
+ co_yield i;
105
+ co_return ;
106
+ }
107
+
108
+ co_returnable_value co_yield_and_return_value (int i) {
109
+ co_yield i;
110
+ co_return (i + 1 );
111
+ }
112
+
113
+
114
+
115
+ // semmle-extractor-options: --edg --c++20
0 commit comments