diff --git a/include/async/algorithm.hpp b/include/async/algorithm.hpp index 9f8d25a..ce07907 100644 --- a/include/async/algorithm.hpp +++ b/include/async/algorithm.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -141,7 +142,7 @@ template struct [[nodiscard]] transform_sender; template -requires (!std::is_same_v) +requires (!std::same_as) struct [[nodiscard]] transform_sender { using value_type = std::invoke_result_t; @@ -160,7 +161,7 @@ struct [[nodiscard]] transform_sender { }; template -requires std::is_same_v +requires std::same_as struct [[nodiscard]] transform_sender { using value_type = std::invoke_result_t; diff --git a/include/async/basic.hpp b/include/async/basic.hpp index 508449e..da693c1 100644 --- a/include/async/basic.hpp +++ b/include/async/basic.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include @@ -140,11 +142,12 @@ struct [[nodiscard]] sender_awaiter { template struct any_receiver { template + requires ( + std::is_trivially_copyable_v + && sizeof(R) <= sizeof(void *) + && alignof(R) <= alignof(void *) + ) any_receiver(R receiver) { - static_assert(std::is_trivially_copyable_v); - static_assert(sizeof(R) <= sizeof(void *)); - static_assert(alignof(R) <= alignof(void *)); - new (stor_) R(receiver); set_value_fptr_ = [] (void *p, T value) { auto *rp = static_cast(p); @@ -168,8 +171,12 @@ struct any_receiver { template<> struct any_receiver { template + requires ( + std::is_trivially_copyable_v + && sizeof(R) <= sizeof(void *) + && alignof(R) <= alignof(void *) + ) any_receiver(R receiver) { - static_assert(std::is_trivially_copyable_v); new (stor_) R(receiver); set_value_fptr_ = [] (void *p) { auto *rp = static_cast(p); @@ -211,10 +218,13 @@ struct callback { callback() : _function(nullptr) { } - template::value - && std::is_trivially_destructible::value>> + template + requires ( + sizeof(F) <= sizeof(void*) + && alignof(F) <= alignof(void*) + && std::is_trivially_copy_constructible_v + && std::is_trivially_destructible_v + ) callback(F functor) : _function(&invoke) { new (&_object) F{std::move(functor)}; @@ -307,8 +317,8 @@ void run_forever(IoService ios) { } template -std::enable_if_t, void> -run(Sender s) { +requires std::same_as +void run(Sender s) { struct receiver { void set_value_inline() { } @@ -323,9 +333,8 @@ run(Sender s) { } template -std::enable_if_t, - typename Sender::value_type> -run(Sender s) { +requires (!std::same_as) +typename Sender::value_type run(Sender s) { struct state { frg::optional value; }; @@ -356,8 +365,8 @@ run(Sender s) { } template -std::enable_if_t, void> -run(Sender s, IoService ios) { +requires std::same_as +void run(Sender s, IoService ios) { struct state { bool done = false; }; @@ -390,9 +399,8 @@ run(Sender s, IoService ios) { } template -std::enable_if_t, - typename Sender::value_type> -run(Sender s, IoService ios) { +requires (!std::same_as) +typename Sender::value_type run(Sender s, IoService ios) { struct state { bool done = false; frg::optional value; diff --git a/include/async/execution.hpp b/include/async/execution.hpp index 25d31a6..528bd3b 100644 --- a/include/async/execution.hpp +++ b/include/async/execution.hpp @@ -2,154 +2,125 @@ #include #include +#include -namespace async { - -// Detection pattern boilerplate. - -template -using void_t = void; - -template -constexpr bool dependent_false_t = false; - -template