Skip to content

Commit

Permalink
Coroutine support is no longer experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
rollbear committed Jan 1, 2024
1 parent 52054de commit 8c49ee2
Show file tree
Hide file tree
Showing 23 changed files with 27 additions and 64 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Coroutines are conditionally supported by the __cpp_impl_coroutine
feature test macro. There is no longer any need to define the
TROMPELOEIL_EXPERIMENTAL_COROUTINES macro in order to use coroutines
with Trompeloeil.

* Split the monolithinc "trompeloeil.hpp" into several smaller
headers. You can continue to #include <trompeloeil.hpp> as usual,
but you can also do more fine grained #include:s, which may
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_return_and_co_throw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_THROW and CO_RETURN does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Expression type does not match the coroutine promise type

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_return_from_non_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_RETURN when return type is not a coroutine

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct MS
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_return_on_forbidden_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_RETURN for forbidden call does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_return_value_to_void_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Expression type does not match the coroutine promise type

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_return_with_mismatching_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Expression type does not match the coroutine promise type

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_throw_and_co_return.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_THROW and CO_RETURN does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_throw_from_non_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Do not use CO_THROW from a normal function, use THROW

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct MS
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_throw_on_forbidden_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_THROW for forbidden call does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_yield_from_non_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_YIELD when return type is not a coroutine

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_YIELD is incompatible with the promise type

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_yield_void.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: You cannot CO_YIELD void

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/co_yield_with_mistamching_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_YIELD is incompatible with the promise type

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: CO_RETURN missing for coroutine

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/multiple_co_return.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Multiple CO_RETURN does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/multiple_co_throw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Multiple CO_THROW does not make sense

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/return_from_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Do not use RETURN from a coroutine, use CO_RETURN

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
1 change: 0 additions & 1 deletion compilation_errors/throw_from_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// exception: macOS\|g++-10\|clang++-1[0-3]\|c++1[147]
// pass: Do not use THROW from a coroutine, use CO_THROW

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>

struct task
Expand Down
5 changes: 3 additions & 2 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,9 @@ There is experimental support to handle
[`co_yield`](https://en.cppreference.com/w/cpp/language/coroutines#co_yield) from member
functions that return a co-routine type.

To enable the experimental support, you must `#define` `TROMPELOEIL_EXPERIMENTAL_COROUTINES`
before `#include` of a *Trompeleil* header.
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

See the reference manual for [**`CO_RETURN(`** *expr* **`)`**](reference.md#CO_RETURN),
[**`LR_CO_RETURN(`** *expr* **`)`**](reference.md#LR_CO_RETURN),
Expand Down
58 changes: 18 additions & 40 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,10 @@ coroutine promise type. This code may alter out-parameters.

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```

**NOTE!** Be very extra careful with lifetime issues when dealing with coroutines.

Expand All @@ -832,13 +829,9 @@ coroutine promise type. This code may alter out-parameters.

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

**NOTE!** Be very extra careful with lifetime issues when dealing with coroutines.

Expand All @@ -857,13 +850,9 @@ See also [**`LR_CO_YIELD(`** *expr* **`]`**](#LR_CO_YIELD)

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

**NOTE!** Be very extra careful with lifetime issues when dealing with coroutines.

Expand Down Expand Up @@ -1155,13 +1144,9 @@ coroutine promise type. This code may alter out-parameters.

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

**NOTE!** Any named local objects named in *expr* are captured by reference so
lifetime management is important.
Expand All @@ -1179,13 +1164,9 @@ coroutine promise type. This code may alter out-parameters.

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

**NOTE!** Any named local objects named in *expr* are captured by reference so
lifetime management is important.
Expand All @@ -1207,13 +1188,10 @@ See also [**`CO_YIELD(`** *expr* **`]`**](#LR_CO_YIELD)

`#include <trompeloeil/coro.hpp>`

Coroutine support must be explicitly enabled by defining
**`TROMPELOEIL_EXPERIMENTAL_COROUTINES`** before including the header.
Coroutines are supported if the compiler defines the
[**`__cpp_impl_coroutines`**](https://eel.is/c++draft/cpp.predefined#:__cpp_impl_coroutine)
feature test macro.

```Cpp
#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil.hpp>
```
**NOTE!** Any named local objects named in *expr* are captured by reference so
lifetime management is important.

Expand Down
4 changes: 1 addition & 3 deletions include/trompeloeil/coro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#define TROMPELOEIL_CORO_HPP

#if defined(__cpp_impl_coroutine)
# ifdef TROMPELOEIL_EXPERIMENTAL_COROUTINES
# define TROMPELOEIL_COROUTINES_SUPPORTED 1
# endif
# define TROMPELOEIL_COROUTINES_SUPPORTED 1
#else
# error "Coroutines are not supported by this compiler"
#endif
Expand Down
1 change: 0 additions & 1 deletion test/test_co_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#ifdef __cpp_impl_coroutine

#define TROMPELOEIL_EXPERIMENTAL_COROUTINES
#include <trompeloeil/mock.hpp>
#include <trompeloeil/coro.hpp>

Expand Down

0 comments on commit 8c49ee2

Please sign in to comment.