diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 8ff1f41f1..bb716031a 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -49,9 +49,29 @@ stdexec should follow. the `include/exec` directory, export them with `STDEXEC_MODULE_EXPORT_AUTHORING`. -* The first non-comment, non-blank line in a test file should be - `#include ` so as not to break the modules build. - If compile-time behavior needs to differ between modularized and - traditional builds, the next inclusion should be - `#include ` so that `STDEXEC_USE_MODULES()` - is defined and can be checked. +* In tests, the include order should be: + ```c++ + /* Copyright... */ + + // Catch2 must come before any potential import statements + #include + + // Pull in all the macros in __config.hpp and either include all of + // stdexec's headers, or import stdexec, as appropriate + #include + + // other non-std headers, like anything in or in the test + // utility library + #include + #include + + // if the test has direct dependencies on std, the declarations thereof + // must come last, either as import std, or the usual includes. This has + // to come last because current compilers support including std headers + // *before* import std, but not *after*. + #if STDEXEC_USE_MODULES() + import std; + #else + # include + #endif + ``` diff --git a/include/exec/any_sender_of.hpp b/include/exec/any_sender_of.hpp index 47d6518b8..d39901304 100644 --- a/include/exec/any_sender_of.hpp +++ b/include/exec/any_sender_of.hpp @@ -15,14 +15,21 @@ */ #pragma once -#include "../stdexec/__detail/__any.hpp" -#include "../stdexec/__detail/__concepts.hpp" -#include "../stdexec/__detail/__receiver_ref.hpp" -#include "../stdexec/__detail/__receivers.hpp" +#include "../stdexec/__detail/__config.hpp" +#include "../stdexec/__detail/__receiver_ref.hpp" #include "env.hpp" -#include +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../stdexec/__detail/__any.hpp" +# include "../stdexec/__detail/__concepts.hpp" +# include "../stdexec/__detail/__receivers.hpp" + +# include +#endif STDEXEC_PRAGMA_PUSH() STDEXEC_PRAGMA_IGNORE_GNU("-Woverloaded-virtual") diff --git a/include/exec/asio/as_default_on.hpp b/include/exec/asio/as_default_on.hpp index 040bf2eae..d2d3c5a1a 100644 --- a/include/exec/asio/as_default_on.hpp +++ b/include/exec/asio/as_default_on.hpp @@ -20,10 +20,16 @@ #include +#include "../../stdexec/__detail/__config.hpp" + #include "executor_with_default.hpp" -#include -#include +#if STDEXEC_USE_MODULES() +import std; +#else +# include +# include +#endif namespace experimental::execution::asio { diff --git a/include/exec/asio/completion_token.hpp b/include/exec/asio/completion_token.hpp index f8ad7b2cb..a1401dead 100644 --- a/include/exec/asio/completion_token.hpp +++ b/include/exec/asio/completion_token.hpp @@ -20,25 +20,33 @@ #include -#include "../../stdexec/__detail/__execution_fwd.hpp" - -#include "../../stdexec/__detail/__completion_signatures_of.hpp" -#include "../../stdexec/__detail/__env.hpp" -#include "../../stdexec/__detail/__queries.hpp" -#include "../../stdexec/__detail/__receivers.hpp" -#include "../../stdexec/__detail/__type_traits.hpp" -#include "../../stdexec/stop_token.hpp" -#include "as_default_on.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../../stdexec/__detail/__config.hpp" + +# include "as_default_on.hpp" + +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../../stdexec/__detail/__execution_fwd.hpp" + +# include "../../stdexec/__detail/__completion_signatures_of.hpp" +# include "../../stdexec/__detail/__env.hpp" +# include "../../stdexec/__detail/__queries.hpp" +# include "../../stdexec/__detail/__receivers.hpp" +# include "../../stdexec/__detail/__type_traits.hpp" +# include "../../stdexec/stop_token.hpp" + +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif namespace experimental::execution::asio { diff --git a/include/exec/asio/noexcept_boost_throw.hpp b/include/exec/asio/noexcept_boost_throw.hpp index a829a59c4..f4014825a 100644 --- a/include/exec/asio/noexcept_boost_throw.hpp +++ b/include/exec/asio/noexcept_boost_throw.hpp @@ -27,8 +27,12 @@ # include # include -# include -# include +# if STDEXEC_USE_MODULES() +import std; +# else +# include +# include +# endif namespace boost { diff --git a/include/exec/asio/use_sender.hpp b/include/exec/asio/use_sender.hpp index 760b7b8d4..46195a6fa 100644 --- a/include/exec/asio/use_sender.hpp +++ b/include/exec/asio/use_sender.hpp @@ -20,22 +20,29 @@ #include -#include "../../stdexec/__detail/__execution_fwd.hpp" - -#include "../../stdexec/__detail/__completion_signatures_of.hpp" -#include "../../stdexec/__detail/__receivers.hpp" -#include "../../stdexec/__detail/__senders.hpp" -#include "../../stdexec/__detail/__transform_completion_signatures.hpp" -#include "../../stdexec/__detail/__type_traits.hpp" +#include "../../stdexec/__detail/__config.hpp" #include "as_default_on.hpp" #include "completion_token.hpp" -#include -#include -#include -#include -#include +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../../stdexec/__detail/__execution_fwd.hpp" + +# include "../../stdexec/__detail/__completion_signatures_of.hpp" +# include "../../stdexec/__detail/__receivers.hpp" +# include "../../stdexec/__detail/__senders.hpp" +# include "../../stdexec/__detail/__transform_completion_signatures.hpp" +# include "../../stdexec/__detail/__type_traits.hpp" + +# include +# include +# include +# include +# include +#endif namespace experimental::execution::asio { @@ -71,7 +78,7 @@ namespace experimental::execution::asio : r_(static_cast(t)) {} - using receiver_concept = ::STDEXEC::receiver_t; + using receiver_concept = ::STDEXEC::receiver_tag; constexpr void set_stopped() && noexcept requires ::STDEXEC::receiver_of< diff --git a/include/exec/async_scope.hpp b/include/exec/async_scope.hpp index 0ade14061..819e16277 100644 --- a/include/exec/async_scope.hpp +++ b/include/exec/async_scope.hpp @@ -130,7 +130,7 @@ namespace experimental::execution template <__decays_to<__when_empty_sender> _Self, class... _Env> static consteval auto get_completion_signatures() - -> __completion_signatures_of_t<__copy_cvref_t<_Self, _Constrained>, __env_t<_Env>...> + -> completion_signatures_of_t<__copy_cvref_t<_Self, _Constrained>, __env_t<_Env>...> { return {}; } @@ -256,7 +256,7 @@ namespace experimental::execution template <__decays_to<__nest_sender> _Self, class... _Env> static consteval auto get_completion_signatures() - -> __completion_signatures_of_t<__copy_cvref_t<_Self, _Constrained>, __env_t<_Env>...> + -> completion_signatures_of_t<__copy_cvref_t<_Self, _Constrained>, __env_t<_Env>...> { return {}; } diff --git a/include/exec/detail/basic_sequence.hpp b/include/exec/detail/basic_sequence.hpp index 0357b7a0c..118a08b27 100644 --- a/include/exec/detail/basic_sequence.hpp +++ b/include/exec/detail/basic_sequence.hpp @@ -16,10 +16,16 @@ */ #pragma once -#include "../../stdexec/__detail/__basic_sender.hpp" #include "../../stdexec/__detail/__config.hpp" -#include "../../stdexec/__detail/__meta.hpp" +#if STDEXEC_USE_MODULES() +import stdexec; +#else +# include "../../stdexec/__detail/__basic_sender.hpp" +# include "../../stdexec/__detail/__meta.hpp" +#endif + +#include "../../stdexec/__detail/__basic_sender_macros.hpp" #include "../sequence_senders.hpp" namespace experimental::execution diff --git a/include/exec/env.hpp b/include/exec/env.hpp index c7544a9f8..faab71b08 100644 --- a/include/exec/env.hpp +++ b/include/exec/env.hpp @@ -15,7 +15,13 @@ */ #pragma once -#include "../stdexec/execution.hpp" +#include "../stdexec/__detail/__config.hpp" + +#if STDEXEC_USE_MODULES() +import stdexec; +#else +# include "../stdexec/execution.hpp" +#endif STDEXEC_PRAGMA_PUSH() STDEXEC_PRAGMA_IGNORE_EDG(1302) @@ -229,7 +235,7 @@ namespace experimental::execution template <__decays_to<__sender> _Self, class... _Env> static consteval auto get_completion_signatures() - -> __completion_signatures_of_t<__copy_cvref_t<_Self, _Sender>, _Env...> + -> completion_signatures_of_t<__copy_cvref_t<_Self, _Sender>, _Env...> { return {}; } diff --git a/include/exec/sender_for.hpp b/include/exec/sender_for.hpp index 5c87e2466..02a86570f 100644 --- a/include/exec/sender_for.hpp +++ b/include/exec/sender_for.hpp @@ -15,7 +15,13 @@ */ #pragma once -#include "../stdexec/__detail/__sender_introspection.hpp" +#include "../stdexec/__detail/__config.hpp" + +#if STDEXEC_USE_MODULES() +import stdexec; +#else +# include "../stdexec/__detail/__sender_introspection.hpp" +#endif namespace experimental::execution { diff --git a/include/exec/sequence/iterate.hpp b/include/exec/sequence/iterate.hpp index 30e5ce1db..b847431a7 100644 --- a/include/exec/sequence/iterate.hpp +++ b/include/exec/sequence/iterate.hpp @@ -18,15 +18,24 @@ #include "../../stdexec/__detail/__config.hpp" -#include "../../stdexec/__detail/__concepts.hpp" -#include "../../stdexec/__detail/__connect.hpp" -#include "../../stdexec/__detail/__env.hpp" -#include "../../stdexec/__detail/__execution_fwd.hpp" -#include "../../stdexec/__detail/__operation_states.hpp" -#include "../../stdexec/__detail/__optional.hpp" -#include "../../stdexec/__detail/__receivers.hpp" -#include "../../stdexec/__detail/__schedulers.hpp" -#include "../../stdexec/__detail/__sender_concepts.hpp" +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../../stdexec/__detail/__execution_fwd.hpp" + +# include "../../stdexec/__detail/__concepts.hpp" +# include "../../stdexec/__detail/__connect.hpp" +# include "../../stdexec/__detail/__env.hpp" +# include "../../stdexec/__detail/__operation_states.hpp" +# include "../../stdexec/__detail/__optional.hpp" +# include "../../stdexec/__detail/__receivers.hpp" +# include "../../stdexec/__detail/__schedulers.hpp" +# include "../../stdexec/__detail/__sender_concepts.hpp" + +# include +# include +#endif #include "../detail/basic_sequence.hpp" #include "../sender_for.hpp" @@ -34,9 +43,6 @@ #include "../sequence_senders.hpp" #include "../trampoline_scheduler.hpp" -#include -#include - namespace experimental::execution { namespace __iterate diff --git a/include/exec/sequence_senders.hpp b/include/exec/sequence_senders.hpp index 8cd61ca1d..668fc0cc1 100644 --- a/include/exec/sequence_senders.hpp +++ b/include/exec/sequence_senders.hpp @@ -16,24 +16,31 @@ */ #pragma once -#include "../stdexec/__detail/__execution_fwd.hpp" - -#include "../stdexec/__detail/__completion_signatures.hpp" -#include "../stdexec/__detail/__concepts.hpp" -#include "../stdexec/__detail/__connect.hpp" -#include "../stdexec/__detail/__debug.hpp" -#include "../stdexec/__detail/__diagnostics.hpp" -#include "../stdexec/__detail/__env.hpp" -#include "../stdexec/__detail/__just.hpp" -#include "../stdexec/__detail/__meta.hpp" -#include "../stdexec/__detail/__receivers.hpp" -#include "../stdexec/__detail/__senders.hpp" -#include "../stdexec/__detail/__stop_token.hpp" -#include "../stdexec/__detail/__tag_invoke.hpp" -#include "../stdexec/__detail/__transform_sender.hpp" -#include "../stdexec/__detail/__type_traits.hpp" -#include "../stdexec/__detail/__utility.hpp" -#include "../stdexec/stop_token.hpp" +#include "../stdexec/__detail/__config.hpp" + +#if STDEXEC_USE_MODULES() +import stdexec; +# include "../stdexec/__detail/__diagnostic_macros.hpp" +#else +# include "../stdexec/__detail/__execution_fwd.hpp" + +# include "../stdexec/__detail/__completion_signatures.hpp" +# include "../stdexec/__detail/__concepts.hpp" +# include "../stdexec/__detail/__connect.hpp" +# include "../stdexec/__detail/__debug.hpp" +# include "../stdexec/__detail/__diagnostics.hpp" +# include "../stdexec/__detail/__env.hpp" +# include "../stdexec/__detail/__just.hpp" +# include "../stdexec/__detail/__meta.hpp" +# include "../stdexec/__detail/__receivers.hpp" +# include "../stdexec/__detail/__senders.hpp" +# include "../stdexec/__detail/__stop_token.hpp" +# include "../stdexec/__detail/__tag_invoke.hpp" +# include "../stdexec/__detail/__transform_sender.hpp" +# include "../stdexec/__detail/__type_traits.hpp" +# include "../stdexec/__detail/__utility.hpp" +# include "../stdexec/stop_token.hpp" +#endif #include "completion_signatures.hpp" diff --git a/include/exec/static_thread_pool.hpp b/include/exec/static_thread_pool.hpp index ae664af8c..feb70674e 100644 --- a/include/exec/static_thread_pool.hpp +++ b/include/exec/static_thread_pool.hpp @@ -17,24 +17,43 @@ */ #pragma once -#include "../stdexec/__detail/__atomic.hpp" -#include "../stdexec/__detail/__bulk.hpp" -#include "../stdexec/__detail/__completion_signatures.hpp" -#include "../stdexec/__detail/__concepts.hpp" #include "../stdexec/__detail/__config.hpp" -#include "../stdexec/__detail/__domain.hpp" -#include "../stdexec/__detail/__execution_fwd.hpp" -#include "../stdexec/__detail/__execution_legacy.hpp" -#include "../stdexec/__detail/__get_completion_signatures.hpp" -#include "../stdexec/__detail/__intrusive_queue.hpp" -#include "../stdexec/__detail/__manual_lifetime.hpp" -#include "../stdexec/__detail/__meta.hpp" -#include "../stdexec/__detail/__optional.hpp" -#include "../stdexec/__detail/__receivers.hpp" -#include "../stdexec/__detail/__transform_completion_signatures.hpp" -#include "../stdexec/__detail/__tuple.hpp" -#include "../stdexec/__detail/__type_traits.hpp" -#include "../stdexec/__detail/__variant.hpp" + +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../stdexec/__detail/__atomic.hpp" +# include "../stdexec/__detail/__bulk.hpp" +# include "../stdexec/__detail/__completion_signatures.hpp" +# include "../stdexec/__detail/__concepts.hpp" +# include "../stdexec/__detail/__config.hpp" +# include "../stdexec/__detail/__domain.hpp" +# include "../stdexec/__detail/__execution_fwd.hpp" +# include "../stdexec/__detail/__execution_legacy.hpp" +# include "../stdexec/__detail/__get_completion_signatures.hpp" +# include "../stdexec/__detail/__intrusive_queue.hpp" +# include "../stdexec/__detail/__manual_lifetime.hpp" +# include "../stdexec/__detail/__meta.hpp" +# include "../stdexec/__detail/__optional.hpp" +# include "../stdexec/__detail/__receivers.hpp" +# include "../stdexec/__detail/__transform_completion_signatures.hpp" +# include "../stdexec/__detail/__tuple.hpp" +# include "../stdexec/__detail/__type_traits.hpp" +# include "../stdexec/__detail/__variant.hpp" + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif #include "detail/atomic_intrusive_queue.hpp" #include "detail/bwos_lifo_queue.hpp" @@ -45,18 +64,6 @@ #include "sequence/iterate.hpp" #include "sequence_senders.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - namespace experimental::execution { struct bwos_params diff --git a/include/exec/thread_pool_base.hpp b/include/exec/thread_pool_base.hpp index 9cc3b1e44..f2d8211d2 100644 --- a/include/exec/thread_pool_base.hpp +++ b/include/exec/thread_pool_base.hpp @@ -17,27 +17,34 @@ */ #pragma once -#include "../stdexec/__detail/__execution_fwd.hpp" - -#include "../stdexec/__detail/__connect.hpp" -#include "../stdexec/__detail/__env.hpp" -#include "../stdexec/__detail/__meta.hpp" -#include "../stdexec/__detail/__operation_states.hpp" -#include "../stdexec/__detail/__receivers.hpp" -#include "../stdexec/__detail/__schedulers.hpp" -#include "../stdexec/__detail/__transform_completion_signatures.hpp" -#include "../stdexec/__detail/__type_traits.hpp" +#include "../stdexec/__detail/__config.hpp" #include "sender_for.hpp" #include "static_thread_pool.hpp" -#include -#include -#include -#include -#include -#include -#include +#if STDEXEC_USE_MODULES() +import std; +import stdexec; +#else +# include "../stdexec/__detail/__execution_fwd.hpp" + +# include "../stdexec/__detail/__connect.hpp" +# include "../stdexec/__detail/__env.hpp" +# include "../stdexec/__detail/__meta.hpp" +# include "../stdexec/__detail/__operation_states.hpp" +# include "../stdexec/__detail/__receivers.hpp" +# include "../stdexec/__detail/__schedulers.hpp" +# include "../stdexec/__detail/__transform_completion_signatures.hpp" +# include "../stdexec/__detail/__type_traits.hpp" + +# include +# include +# include +# include +# include +# include +# include +#endif namespace experimental::execution { diff --git a/include/stdexec/__detail/__affine.hpp b/include/stdexec/__detail/__affine.hpp index d0e6ac1cf..2306561ec 100644 --- a/include/stdexec/__detail/__affine.hpp +++ b/include/stdexec/__detail/__affine.hpp @@ -15,14 +15,22 @@ */ #pragma once -#include "__basic_sender.hpp" -#include "__completion_behavior.hpp" -#include "__finally.hpp" -#include "__schedulers.hpp" -#include "__senders.hpp" -#include "__unstoppable.hpp" +#include "__config.hpp" -#include "__prologue.hpp" +#if STDEXEC_USE_MODULES() && !defined(STDEXEC_IN_MODULE_PURVIEW) + +import stdexec; + +#else + +# include "__basic_sender.hpp" +# include "__completion_behavior.hpp" +# include "__finally.hpp" +# include "__schedulers.hpp" +# include "__senders.hpp" +# include "__unstoppable.hpp" + +# include "__prologue.hpp" namespace STDEXEC { @@ -179,4 +187,5 @@ namespace STDEXEC }; } // namespace STDEXEC -#include "__epilogue.hpp" +# include "__epilogue.hpp" +#endif // !STDEXEC_USE_MODULES() || defined(STDEXEC_IN_MODULE_PURVIEW) diff --git a/include/stdexec/__detail/__any.hpp b/include/stdexec/__detail/__any.hpp index 014cb9462..849233c6a 100644 --- a/include/stdexec/__detail/__any.hpp +++ b/include/stdexec/__detail/__any.hpp @@ -50,6 +50,10 @@ STDEXEC_PRAGMA_IGNORE_GNU("-Warray-bounds") // NOLINTBEGIN(moderize-use-override) +STDEXEC_MODULE_EXPORT_AUTHORING +namespace STDEXEC::__any +{} + namespace STDEXEC::__any { @@ -165,25 +169,31 @@ namespace STDEXEC::__any template