From e6bad7be5aba895263c0a4fead9a37ccc8b95af5 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 14 Feb 2021 14:29:34 -0800 Subject: [PATCH 001/112] work around absence of type traits variable tempates --- examples/any_unique.cpp | 2 +- include/unifex/allocate.hpp | 2 +- include/unifex/any_unique.hpp | 4 +- include/unifex/at_coroutine_exit.hpp | 2 +- include/unifex/await_transform.hpp | 6 +- include/unifex/bulk_join.hpp | 8 +- include/unifex/bulk_schedule.hpp | 4 +- include/unifex/bulk_transform.hpp | 25 ++--- include/unifex/config.hpp.in | 9 +- include/unifex/continuations.hpp | 2 +- include/unifex/dematerialize.hpp | 11 ++- include/unifex/executor_concepts.hpp | 4 +- include/unifex/finally.hpp | 8 +- include/unifex/find_if.hpp | 13 +-- include/unifex/for_each.hpp | 3 +- include/unifex/functional.hpp | 42 +++++++++ include/unifex/indexed_for.hpp | 7 +- include/unifex/inline_scheduler.hpp | 2 +- include/unifex/inplace_stop_token.hpp | 2 +- include/unifex/just.hpp | 6 +- include/unifex/just_error.hpp | 6 +- include/unifex/let.hpp | 8 +- include/unifex/let_with.hpp | 7 +- include/unifex/let_with_stop_source.hpp | 7 +- include/unifex/linux/io_uring_context.hpp | 2 +- include/unifex/manual_lifetime.hpp | 14 +-- include/unifex/manual_lifetime_union.hpp | 4 +- include/unifex/materialize.hpp | 11 ++- include/unifex/receiver_concepts.hpp | 6 +- include/unifex/reduce_stream.hpp | 2 +- include/unifex/repeat_effect_until.hpp | 37 ++++---- include/unifex/retry_when.hpp | 29 +++--- include/unifex/scope_guard.hpp | 4 +- include/unifex/sender_concepts.hpp | 10 +- include/unifex/sequence.hpp | 8 +- include/unifex/span.hpp | 10 +- include/unifex/std_concepts.hpp | 12 +-- include/unifex/stop_immediately.hpp | 2 +- include/unifex/stop_token_concepts.hpp | 8 +- include/unifex/stop_when.hpp | 14 +-- include/unifex/submit.hpp | 2 +- include/unifex/tag_invoke.hpp | 4 +- include/unifex/task.hpp | 8 +- include/unifex/transform.hpp | 10 +- include/unifex/transform_done.hpp | 14 +-- include/unifex/type_index.hpp | 2 +- include/unifex/type_traits.hpp | 91 +++++++++++++++---- .../unifex/win32/low_latency_iocp_context.hpp | 8 +- include/unifex/win32/windows_thread_pool.hpp | 2 +- include/unifex/with_query_value.hpp | 5 +- test/any_sender_of_test.cpp | 4 +- test/any_unique_test.cpp | 4 +- test/tag_invoke_test.cpp | 5 +- 53 files changed, 322 insertions(+), 200 deletions(-) create mode 100644 include/unifex/functional.hpp diff --git a/examples/any_unique.cpp b/examples/any_unique.cpp index d92b37b88..9c4145739 100644 --- a/examples/any_unique.cpp +++ b/examples/any_unique.cpp @@ -38,7 +38,7 @@ inline constexpr struct get_typeid_cpo { auto operator()(const T& x) const noexcept -> unifex::tag_invoke_result_t { static_assert( - std::is_same_v< + unifex::is_same_v< unifex::type_index, unifex::tag_invoke_result_t>); return tag_invoke(get_typeid_cpo{}, x); diff --git a/include/unifex/allocate.hpp b/include/unifex/allocate.hpp index 6613ed6b1..cd0894fa4 100644 --- a/include/unifex/allocate.hpp +++ b/include/unifex/allocate.hpp @@ -129,7 +129,7 @@ namespace _alloc_cpo { template(typename Sender) (requires (!tag_invocable<_fn, Sender>)) auto operator()(Sender&& predecessor) const - noexcept(std::is_nothrow_constructible_v<_alloc::sender, Sender>) + noexcept(is_nothrow_constructible_v<_alloc::sender, Sender>) -> _result_t { return _alloc::sender{(Sender &&) predecessor}; } diff --git a/include/unifex/any_unique.hpp b/include/unifex/any_unique.hpp index fafc8f83f..b1353662a 100644 --- a/include/unifex/any_unique.hpp +++ b/include/unifex/any_unique.hpp @@ -300,8 +300,8 @@ struct _concrete_impl { template explicit base(std::allocator_arg_t, allocator_type alloc, Args&&... args) - noexcept(std::is_nothrow_move_constructible_v && - std::is_nothrow_constructible_v) + noexcept(is_nothrow_move_constructible_v && + is_nothrow_constructible_v) : value((Args &&) args...) , alloc(std::move(alloc)) {} diff --git a/include/unifex/at_coroutine_exit.hpp b/include/unifex/at_coroutine_exit.hpp index 5f9296394..afb3c1b88 100644 --- a/include/unifex/at_coroutine_exit.hpp +++ b/include/unifex/at_coroutine_exit.hpp @@ -184,7 +184,7 @@ struct _die_on_done_fn { template (typename Value) (requires (!detail::_awaitable) AND sender) _die_on_done_t operator()(Value&& value) /*mutable*/ - noexcept(std::is_nothrow_constructible_v, Value>) { + noexcept(is_nothrow_constructible_v, Value>) { return _die_on_done_t{(Value&&) value}; } diff --git a/include/unifex/await_transform.hpp b/include/unifex/await_transform.hpp index 7c82efc08..6084b2d93 100644 --- a/include/unifex/await_transform.hpp +++ b/include/unifex/await_transform.hpp @@ -96,10 +96,10 @@ struct _awaitable_base::type { template(class... Us) (requires (constructible_from || - (std::is_void_v && sizeof...(Us) == 0))) + (is_void_v && sizeof...(Us) == 0))) void set_value(Us&&... us) && - noexcept(std::is_nothrow_constructible_v || - std::is_void_v) { + noexcept(is_nothrow_constructible_v || + is_void_v) { unifex::activate_union_member(result_->value_, (Us&&) us...); result_->state_ = _state::value; continuation_.resume(); diff --git a/include/unifex/bulk_join.hpp b/include/unifex/bulk_join.hpp index 6a64d3e91..a9dcc37ce 100644 --- a/include/unifex/bulk_join.hpp +++ b/include/unifex/bulk_join.hpp @@ -41,7 +41,7 @@ class _join_receiver::type { public: template(typename Receiver2) (requires constructible_from) - explicit type(Receiver2&& r) noexcept(std::is_nothrow_constructible_v) + explicit type(Receiver2&& r) noexcept(is_nothrow_constructible_v) : receiver_((Receiver2&&)r) {} @@ -103,7 +103,7 @@ class _join_sender::type { template explicit type(Source2&& s) - noexcept(std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v) : source_((Source2&&)s) {} @@ -113,7 +113,7 @@ class _join_sender::type { sender_to, join_receiver>>) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( - std::is_nothrow_constructible_v> && + is_nothrow_constructible_v> && is_nothrow_connectable_v, join_receiver>>) -> connect_result_t, join_receiver>> { @@ -142,7 +142,7 @@ struct _fn { typed_bulk_sender && (!tag_invocable<_fn, Source>)) auto operator()(Source&& source) const - noexcept(std::is_nothrow_constructible_v, Source>) + noexcept(is_nothrow_constructible_v, Source>) -> join_sender> { return join_sender>{ (Source&&)source}; diff --git a/include/unifex/bulk_schedule.hpp b/include/unifex/bulk_schedule.hpp index ebdbf62a5..36e8ff9c0 100644 --- a/include/unifex/bulk_schedule.hpp +++ b/include/unifex/bulk_schedule.hpp @@ -206,8 +206,8 @@ struct _fn { (!tag_invocable<_fn, Scheduler, Integral>)) auto operator()(Scheduler&& s, Integral n) const noexcept( - std::is_nothrow_constructible_v, Scheduler> && - std::is_nothrow_move_constructible_v) + is_nothrow_constructible_v, Scheduler> && + is_nothrow_move_constructible_v) -> default_sender, Integral> { return default_sender, Integral>{(Scheduler&&)s, std::move(n)}; } diff --git a/include/unifex/bulk_transform.hpp b/include/unifex/bulk_transform.hpp index ae2c72987..bac87fbd2 100644 --- a/include/unifex/bulk_transform.hpp +++ b/include/unifex/bulk_transform.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -49,10 +50,10 @@ class _tfx_receiver::type { template(typename... Values) (requires invocable AND - std::is_void_v>) + is_void_v>) void set_next(Values&&... values) & noexcept( - std::is_nothrow_invocable_v && + is_nothrow_invocable_v && is_nothrow_next_receiver_v) { std::invoke(func_, (Values&&)values...); unifex::set_next(receiver_); @@ -61,10 +62,10 @@ class _tfx_receiver::type { template(typename... Values) (requires invocable AND - (!std::is_void_v>)) + (!is_void_v>)) void set_next(Values&&... values) & noexcept( - std::is_nothrow_invocable_v && + is_nothrow_invocable_v && is_nothrow_next_receiver_v>) { unifex::set_next(receiver_, std::invoke(func_, (Values&&)values...)); } @@ -134,7 +135,7 @@ struct result_overload { using type = type_list; }; template -struct result_overload>> { +struct result_overload>> { using type = type_list<>; }; @@ -176,10 +177,10 @@ class _tfx_sender::type { sender_to, tfx_receiver>>) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v, Receiver>) { + is_nothrow_constructible_v> && + is_nothrow_constructible_v> && + is_nothrow_constructible_v> && + is_nothrow_constructible_v, Receiver>) { return unifex::connect( static_cast(self).source_, tfx_receiver>{ @@ -219,9 +220,9 @@ struct _fn { (!tag_invocable<_fn, Source, Func, FuncPolicy>)) auto operator()(Source&& s, Func&& f, FuncPolicy policy) const noexcept( - std::is_nothrow_constructible_v, Source> && - std::is_nothrow_constructible_v, Func> && - std::is_nothrow_move_constructible_v) + is_nothrow_constructible_v, Source> && + is_nothrow_constructible_v, Func> && + is_nothrow_move_constructible_v) -> tfx_sender, remove_cvref_t, FuncPolicy> { return tfx_sender, remove_cvref_t, FuncPolicy>{ (Source&&)s, (Func&&)f, std::move(policy) diff --git a/include/unifex/config.hpp.in b/include/unifex/config.hpp.in index d92ff3a30..db887960a 100644 --- a/include/unifex/config.hpp.in +++ b/include/unifex/config.hpp.in @@ -126,7 +126,7 @@ #if defined(_MSC_VER) # define UNIFEX_DECLARE_NON_DEDUCED_TYPE(NAME, ...) \ typename NAME, \ - std::enable_if_t, int> = 0 + std::enable_if_t, int> = 0 # define UNIFEX_USE_NON_DEDUCED_TYPE(NAME, ...) NAME #else # define UNIFEX_DECLARE_NON_DEDUCED_TYPE(NAME, ...) typename NAME = __VA_ARGS__ @@ -161,6 +161,13 @@ # define UNIFEX_RETHROW() ((void)0) #endif +#if (defined(__cpp_lib_type_trait_variable_templates) && \ + __cpp_lib_type_trait_variable_templates > 0) +#define UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES 1 +#else +#define UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES 0 +#endif + #if defined(_MSC_VER) && !defined(__clang__) #define UNIFEX_DIAGNOSTIC_PUSH __pragma(warning(push)) #define UNIFEX_DIAGNOSTIC_POP __pragma(warning(pop)) diff --git a/include/unifex/continuations.hpp b/include/unifex/continuations.hpp index 2fd6b0263..8780d6ced 100644 --- a/include/unifex/continuations.hpp +++ b/include/unifex/continuations.hpp @@ -46,7 +46,7 @@ namespace _visit_continuations_cpo { const Continuation&, Func&&>) { static_assert( - std::is_void_v>, diff --git a/include/unifex/dematerialize.hpp b/include/unifex/dematerialize.hpp index 9e6b1d193..8bbb7735e 100644 --- a/include/unifex/dematerialize.hpp +++ b/include/unifex/dematerialize.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -44,7 +45,7 @@ namespace _demat { template(typename Receiver2) (requires constructible_from) explicit type(Receiver2&& receiver) noexcept( - std::is_nothrow_constructible_v) + is_nothrow_constructible_v) : receiver_(static_cast(receiver)) {} template(typename CPO, typename... Values) @@ -96,7 +97,7 @@ namespace _demat { template struct apply_impl : std::conditional< - std::is_base_of_v>, + is_base_of_v>, type_list>, type_list<>> {}; @@ -162,7 +163,7 @@ namespace _demat { template explicit type(Source2&& source) - noexcept(std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v) : source_(static_cast(source)) {} template(typename Self, typename Receiver) @@ -170,7 +171,7 @@ namespace _demat { sender_to, receiver_t>) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept(is_nothrow_connectable_v, receiver_t> && - std::is_nothrow_constructible_v, Receiver>) + is_nothrow_constructible_v, Receiver>) -> connect_result_t, receiver_t> { return unifex::connect( static_cast(self).source_, @@ -202,7 +203,7 @@ namespace _demat_cpo { template(typename Sender) (requires (!tag_invocable<_fn, Sender>)) auto operator()(Sender&& predecessor) const - noexcept(std::is_nothrow_constructible_v, Sender>) + noexcept(is_nothrow_constructible_v, Sender>) -> _result_t { return _demat::sender{(Sender &&) predecessor}; } diff --git a/include/unifex/executor_concepts.hpp b/include/unifex/executor_concepts.hpp index 2b9beead2..36f2f05c8 100644 --- a/include/unifex/executor_concepts.hpp +++ b/include/unifex/executor_concepts.hpp @@ -122,7 +122,7 @@ concept // move_constructible> && copy_constructible && equality_comparable && - std::is_nothrow_copy_constructible_v && + is_nothrow_copy_constructible_v && requires(const E e, F&& f) { unifex::execute(e, (F&&) f); }; @@ -142,7 +142,7 @@ UNIFEX_CONCEPT // move_constructible> && copy_constructible && equality_comparable && - std::is_nothrow_copy_constructible_v && + is_nothrow_copy_constructible_v && UNIFEX_FRAGMENT(unifex::_executor_of_impl_part, E, F); #endif diff --git a/include/unifex/finally.hpp b/include/unifex/finally.hpp index 3a3f2b7ef..e9be079b7 100644 --- a/include/unifex/finally.hpp +++ b/include/unifex/finally.hpp @@ -414,7 +414,7 @@ namespace unifex template void set_error(Error&& error) && noexcept { static_assert( - std::is_nothrow_constructible_v, Error>); + is_nothrow_constructible_v, Error>); auto* const op = op_; unifex::activate_union_member>( @@ -659,8 +659,8 @@ namespace unifex template explicit type( SourceSender2&& source, CompletionSender2&& completion) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v) : source_(static_cast(source)) , completion_(static_cast(completion)) {} @@ -706,7 +706,7 @@ namespace unifex inline const struct _fn { template auto operator()(SourceSender&& source, CompletionSender&& completion) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _final::sender, SourceSender, CompletionSender>) -> _final::sender { diff --git a/include/unifex/find_if.hpp b/include/unifex/find_if.hpp index ec4cec707..bdd2a95fa 100644 --- a/include/unifex/find_if.hpp +++ b/include/unifex/find_if.hpp @@ -85,7 +85,8 @@ struct _receiver::type { unpack_helper( (OutputReceiver&&) output_receiver_, std::move(packedResult), - std::make_index_sequence>>{}); + std::make_index_sequence< + std::tuple_size>::value>{}); } UNIFEX_CATCH(...) { unifex::set_error((OutputReceiver&&)output_receiver_, std::current_exception()); } @@ -389,8 +390,8 @@ struct _sender::type { (requires same_as, type> AND receiver) friend auto tag_invoke(tag_t, Sender&& s, Receiver&& r) noexcept( - std::is_nothrow_constructible_v, Receiver> && - std::is_nothrow_constructible_v> && + is_nothrow_constructible_v, Receiver> && + is_nothrow_constructible_v> && is_nothrow_connectable_v< member_t, receiver_type>>) @@ -415,9 +416,9 @@ namespace _find_if_cpo { (requires (!tag_invocable<_fn, Sender, Func, FuncPolicy>)) auto operator()(Sender&& predecessor, Func&& func, FuncPolicy policy) const noexcept( - std::is_nothrow_constructible_v, Sender> && - std::is_nothrow_constructible_v, Func> && - std::is_nothrow_constructible_v, FuncPolicy>) + is_nothrow_constructible_v, Sender> && + is_nothrow_constructible_v, Func> && + is_nothrow_constructible_v, FuncPolicy>) -> _find_if::sender_t, std::decay_t, FuncPolicy>{ return _find_if::sender_t, std::decay_t, FuncPolicy>{ (Sender &&) predecessor, (Func &&) func, (FuncPolicy &&) policy}; diff --git a/include/unifex/for_each.hpp b/include/unifex/for_each.hpp index 8379e9281..1713b031d 100644 --- a/include/unifex/for_each.hpp +++ b/include/unifex/for_each.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -31,7 +32,7 @@ namespace _for_each { template(typename... Ts) (requires invocable) unit operator()(unit s, Ts&&... values) - noexcept(std::is_nothrow_invocable_v) { + noexcept(is_nothrow_invocable_v) { std::invoke(func_, (Ts&&) values...); return s; } diff --git a/include/unifex/functional.hpp b/include/unifex/functional.hpp new file mode 100644 index 000000000..02cfbfc77 --- /dev/null +++ b/include/unifex/functional.hpp @@ -0,0 +1,42 @@ +/* + * Copyright 2019-present Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +#include + +#include + +#if defined(__cpp_lib_invoke) && __cpp_lib_invoke > 0 +#define UNIFEX_CXX_INVOKE 1 +#else +#define UNIFEX_CXX_INVOKE 0 +#endif + +namespace unifex { +#if UNIFEX_CXX_INVOKE + +using std::invoke; + +#else + +#error TODO: IMPLEMENT ME + +#endif +} + +#include diff --git a/include/unifex/indexed_for.hpp b/include/unifex/indexed_for.hpp index 66c9a0a8d..63905ef17 100644 --- a/include/unifex/indexed_for.hpp +++ b/include/unifex/indexed_for.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,7 @@ struct _receiver::type { // sequenced_policy version supports forward range template static void apply_func_with_policy(const execution::sequenced_policy&, Range&& range, Func&& func, Values&... values) - noexcept(std::is_nothrow_invocable_v::reference, Values...>) { + noexcept(is_nothrow_invocable_v::reference, Values...>) { for(auto idx : range) { std::invoke(func, idx, values...); } @@ -63,7 +64,7 @@ struct _receiver::type { // parallel_policy version requires random access range template static void apply_func_with_policy(const execution::parallel_policy&, Range&& range, Func&& func, Values&... values) - noexcept(std::is_nothrow_invocable_v::reference, Values...>) { + noexcept(is_nothrow_invocable_v::reference, Values...>) { auto first = range.begin(); using size_type = decltype(range.size()); for (size_type idx = 0; idx < range.size(); ++idx) { @@ -73,7 +74,7 @@ struct _receiver::type { template void set_value(Values&&... values) && noexcept { - if constexpr (std::is_nothrow_invocable_v::reference, Values...>) { + if constexpr (is_nothrow_invocable_v::reference, Values...>) { apply_func_with_policy(policy_, (Range&&) range_, (Func &&) func_, values...); unifex::set_value((Receiver &&) receiver_, (Values &&) values...); } else { diff --git a/include/unifex/inline_scheduler.hpp b/include/unifex/inline_scheduler.hpp index 619da2328..2d0b36383 100644 --- a/include/unifex/inline_scheduler.hpp +++ b/include/unifex/inline_scheduler.hpp @@ -44,7 +44,7 @@ namespace _inline_sched { template(typename Receiver2) (requires constructible_from) - explicit type(Receiver2&& r) noexcept(std::is_nothrow_constructible_v) + explicit type(Receiver2&& r) noexcept(is_nothrow_constructible_v) : receiver_((Receiver2 &&) r) {} void start() noexcept { diff --git a/include/unifex/inplace_stop_token.hpp b/include/unifex/inplace_stop_token.hpp index 71c7321a3..cd0e6ded2 100644 --- a/include/unifex/inplace_stop_token.hpp +++ b/include/unifex/inplace_stop_token.hpp @@ -176,7 +176,7 @@ class inplace_stop_callback final : private inplace_stop_callback_base { template(typename T) (requires convertible_to) explicit inplace_stop_callback(inplace_stop_token token, T&& func) noexcept( - std::is_nothrow_constructible_v) + is_nothrow_constructible_v) #ifndef NDEBUG : inplace_stop_callback_base(token.source_, &inplace_stop_callback::execute_impl, unifex::type_id().name()) #else diff --git a/include/unifex/just.hpp b/include/unifex/just.hpp index df0851c88..1939f02d2 100644 --- a/include/unifex/just.hpp +++ b/include/unifex/just.hpp @@ -82,7 +82,7 @@ class _sender::type { (requires (sizeof...(Values2) == sizeof...(Values)) AND constructible_from, Values2...>) explicit type(std::in_place_t, Values2&&... values) - noexcept(std::is_nothrow_constructible_v, Values2...>) + noexcept(is_nothrow_constructible_v, Values2...>) : values_((Values2 &&) values...) {} template(typename This, typename Receiver) @@ -90,7 +90,7 @@ class _sender::type { receiver AND constructible_from, member_t>>) friend auto tag_invoke(tag_t, This&& that, Receiver&& r) - noexcept(std::is_nothrow_constructible_v, member_t>>) + noexcept(is_nothrow_constructible_v, member_t>>) -> operation { return {static_cast(that).values_, static_cast(r)}; } @@ -105,7 +105,7 @@ namespace _just_cpo { inline const struct just_fn { template constexpr auto operator()(Values&&... values) const - noexcept(std::is_nothrow_constructible_v<_just::sender, std::in_place_t, Values...>) + noexcept(is_nothrow_constructible_v<_just::sender, std::in_place_t, Values...>) -> _just::sender { return _just::sender{std::in_place, (Values&&)values...}; } diff --git a/include/unifex/just_error.hpp b/include/unifex/just_error.hpp index 3ad878381..fd1b2039d 100644 --- a/include/unifex/just_error.hpp +++ b/include/unifex/just_error.hpp @@ -72,7 +72,7 @@ class _sender::type { template explicit type(std::in_place_t, Error2&& error) - noexcept(std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v) : error_((Error2 &&) error) {} template(typename This, typename Receiver) @@ -80,7 +80,7 @@ class _sender::type { receiver AND constructible_from>) friend auto tag_invoke(tag_t, This&& that, Receiver&& r) - noexcept(std::is_nothrow_constructible_v>) + noexcept(is_nothrow_constructible_v>) -> operation { return {static_cast(that).error_, static_cast(r)}; } @@ -95,7 +95,7 @@ namespace _just_error_cpo { inline const struct just_error_fn { template constexpr auto operator()(Error&& error) const - noexcept(std::is_nothrow_constructible_v, Error>) + noexcept(is_nothrow_constructible_v, Error>) -> _just_error::sender { return _just_error::sender{std::in_place, (Error&&) error}; } diff --git a/include/unifex/let.hpp b/include/unifex/let.hpp index 43cf4b394..b64921e53 100644 --- a/include/unifex/let.hpp +++ b/include/unifex/let.hpp @@ -257,7 +257,7 @@ using sender = typename _sender< remove_cvref_t>::type; template -struct sends_done_impl : std::bool_constant::sends_done> {}; +struct sends_done_impl : bool_constant::sends_done> {}; template using any_sends_done = std::disjunction...>; @@ -325,8 +325,8 @@ class _sender::type { public: template explicit type(Predecessor2&& pred, SuccessorFactory2&& func) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v) : pred_((Predecessor2 &&) pred), func_((SuccessorFactory2 &&) func) {} template(typename CPO, typename Sender, typename Receiver) @@ -347,7 +347,7 @@ namespace _let_cpo { inline const struct _fn { template auto operator()(Predecessor&& pred, SuccessorFactory&& func) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _let::sender, Predecessor, SuccessorFactory>) -> _let::sender { return _let::sender{ diff --git a/include/unifex/let_with.hpp b/include/unifex/let_with.hpp index 6c4d30bcc..1ceb0d3ff 100644 --- a/include/unifex/let_with.hpp +++ b/include/unifex/let_with.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -70,7 +71,7 @@ class _sender::type { friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( is_nothrow_callable_v> && - std::is_nothrow_invocable_v< + is_nothrow_invocable_v< member_t, callable_result_t>&> && is_nothrow_connectable_v< @@ -131,8 +132,8 @@ namespace _let_with_cpo { std::decay_t, callable_result_t>&>>) auto operator()(StateFactory&& stateFactory, SuccessorFactory&& successor_factory) const - noexcept(std::is_nothrow_constructible_v, SuccessorFactory> && - std::is_nothrow_constructible_v, StateFactory>) + noexcept(is_nothrow_constructible_v, SuccessorFactory> && + is_nothrow_constructible_v, StateFactory>) -> _let_with::let_with_sender< std::decay_t, std::decay_t> { return _let_with::let_with_sender< diff --git a/include/unifex/let_with_stop_source.hpp b/include/unifex/let_with_stop_source.hpp index 4a5c9adc5..5cfb28d3c 100644 --- a/include/unifex/let_with_stop_source.hpp +++ b/include/unifex/let_with_stop_source.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -120,8 +121,8 @@ class _stop_source_sender::type { (requires same_as, type> AND receiver) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( - std::is_nothrow_invocable_v, inplace_stop_source&> && - std::is_nothrow_constructible_v, Receiver>) + is_nothrow_invocable_v, inplace_stop_source&> && + is_nothrow_constructible_v, Receiver>) -> operation, Receiver> { return operation, Receiver>( static_cast(self).func_, static_cast(r)); @@ -179,7 +180,7 @@ struct _fn { template auto operator()(SuccessorFactory&& factory) const - noexcept(std::is_nothrow_constructible_v, SuccessorFactory>) + noexcept(is_nothrow_constructible_v, SuccessorFactory>) -> stop_source_sender> { return stop_source_sender>{(SuccessorFactory&&)factory}; } diff --git a/include/unifex/linux/io_uring_context.hpp b/include/unifex/linux/io_uring_context.hpp index 94d8e5f0c..f4c2cbe5d 100644 --- a/include/unifex/linux/io_uring_context.hpp +++ b/include/unifex/linux/io_uring_context.hpp @@ -303,7 +303,7 @@ bool io_uring_context::try_submit_io(PopulateFn populateSqe) noexcept { static_assert(noexcept(populateSqe(sqe))); - if constexpr (std::is_void_v) { + if constexpr (is_void_v) { populateSqe(sqe); } else { if (!populateSqe(sqe)) { diff --git a/include/unifex/manual_lifetime.hpp b/include/unifex/manual_lifetime.hpp index a4c941bd3..812db7e2e 100644 --- a/include/unifex/manual_lifetime.hpp +++ b/include/unifex/manual_lifetime.hpp @@ -29,14 +29,14 @@ namespace unifex { template class manual_lifetime { - static_assert(std::is_nothrow_destructible_v); + static_assert(is_nothrow_destructible_v); public: manual_lifetime() noexcept {} ~manual_lifetime() {} template [[maybe_unused]] T& construct(Args&&... args) noexcept( - std::is_nothrow_constructible_v) { + is_nothrow_constructible_v) { return *::new (static_cast(std::addressof(value_))) T((Args &&) args...); } @@ -44,7 +44,7 @@ class manual_lifetime { template [[maybe_unused]] T& construct_with(Func&& func) noexcept(is_nothrow_callable_v) { static_assert( - std::is_same_v, T>, + is_same_v, T>, "Return type of func() must be exactly T to permit copy-elision."); return *::new (static_cast(std::addressof(value_))) T(((Func &&) func)()); @@ -86,7 +86,7 @@ class manual_lifetime { template [[maybe_unused]] T& construct_with(Func&& func) noexcept(is_nothrow_callable_v) { - static_assert(std::is_same_v, T&>); + static_assert(is_same_v, T&>); value_ = std::addressof(((Func &&) func)()); return get(); } @@ -114,7 +114,7 @@ class manual_lifetime { template [[maybe_unused]] T&& construct_with(Func&& func) noexcept(is_nothrow_callable_v) { - static_assert(std::is_same_v, T&&>); + static_assert(is_same_v, T&&>); value_ = std::addressof(((Func &&) func)()); return get(); } @@ -138,7 +138,7 @@ class manual_lifetime { void construct() noexcept {} template void construct_with(Func&& func) noexcept(is_nothrow_callable_v) { - static_assert(std::is_void_v>); + static_assert(is_void_v>); ((Func &&) func)(); } void destruct() noexcept {} @@ -153,7 +153,7 @@ class manual_lifetime : public manual_lifetime {}; template [[maybe_unused]] // T& activate_union_member(manual_lifetime& box, Args&&... args) noexcept( - std::is_nothrow_constructible_v) { + is_nothrow_constructible_v) { auto* p = ::new (&box) manual_lifetime{}; scope_guard guard = [=]() noexcept { p->~manual_lifetime(); }; auto& t = box.construct(static_cast(args)...); diff --git a/include/unifex/manual_lifetime_union.hpp b/include/unifex/manual_lifetime_union.hpp index 2662f5592..e137064b0 100644 --- a/include/unifex/manual_lifetime_union.hpp +++ b/include/unifex/manual_lifetime_union.hpp @@ -32,7 +32,7 @@ class manual_lifetime_union { template [[maybe_unused]] T& construct(Args&&... args) noexcept( - std::is_nothrow_constructible_v) { + is_nothrow_constructible_v) { return unifex::activate_union_member( *static_cast*>(static_cast(&storage_)), static_cast(args)...); @@ -80,7 +80,7 @@ class manual_lifetime_union<> {}; template [[maybe_unused]] // T& activate_union_member(manual_lifetime_union& box, Args&&... args) // - noexcept(std::is_nothrow_constructible_v) { + noexcept(is_nothrow_constructible_v) { auto* p = ::new (&box) manual_lifetime_union{}; scope_guard guard = [=]() noexcept { p->~manual_lifetime_union(); }; auto& t = p->template construct(static_cast(args)...); diff --git a/include/unifex/materialize.hpp b/include/unifex/materialize.hpp index f34b8cbd0..fa034da16 100644 --- a/include/unifex/materialize.hpp +++ b/include/unifex/materialize.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -45,7 +46,7 @@ namespace unifex template(typename Receiver2) (requires constructible_from) explicit type(Receiver2&& receiver) noexcept( - std::is_nothrow_constructible_v) + is_nothrow_constructible_v) : receiver_(static_cast(receiver)) {} template(typename... Values) @@ -119,7 +120,7 @@ namespace unifex friend void tag_invoke( UNIFEX_USE_NON_DEDUCED_TYPE(CPO, tag_t), const UNIFEX_USE_NON_DEDUCED_TYPE(R, type)& r, - Func&& func) noexcept(std::is_nothrow_invocable_v< + Func&& func) noexcept(is_nothrow_invocable_v< Func&, const Receiver&>) { std::invoke(func, std::as_const(r.receiver_)); @@ -185,7 +186,7 @@ namespace unifex template(typename Source2) (requires constructible_from) explicit type(Source2&& source) noexcept( - std::is_nothrow_constructible_v) + is_nothrow_constructible_v) : source_(static_cast(source)) {} template(typename Self, typename Receiver) @@ -194,7 +195,7 @@ namespace unifex sender_to, receiver_t>) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( is_nothrow_connectable_v, receiver_t> && - std::is_nothrow_constructible_v, Receiver>) + is_nothrow_constructible_v, Receiver>) -> connect_result_t, receiver_t> { return unifex::connect( static_cast(self).source_, @@ -226,7 +227,7 @@ namespace unifex template(typename Source) (requires (!tag_invocable<_fn, Source>)) auto operator()(Source&& source) const - noexcept(std::is_nothrow_constructible_v<_mat::sender, Source>) + noexcept(is_nothrow_constructible_v<_mat::sender, Source>) -> _result_t { return _mat::sender{(Source&&) source}; } diff --git a/include/unifex/receiver_concepts.hpp b/include/unifex/receiver_concepts.hpp index eefd418a7..ccfa90e02 100644 --- a/include/unifex/receiver_concepts.hpp +++ b/include/unifex/receiver_concepts.hpp @@ -110,7 +110,7 @@ namespace _rec_cpo { is_nothrow_tag_invocable_v<_set_error_fn, Receiver, Error>, "set_error() invocation is required to be noexcept."); static_assert( - std::is_void_v> + is_void_v> ); return unifex::tag_invoke( _set_error_fn{}, (Receiver &&) r, (Error&&) error); @@ -146,7 +146,7 @@ namespace _rec_cpo { is_nothrow_tag_invocable_v<_set_done_fn, Receiver>, "set_done() invocation is required to be noexcept."); static_assert( - std::is_void_v> + is_void_v> ); return unifex::tag_invoke(_set_done_fn{}, (Receiver &&) r); } @@ -188,7 +188,7 @@ inline constexpr bool is_receiver_query_cpo_v = !is_one_of_v< _connect_cpo::_fn>; template -using is_receiver_cpo = std::bool_constant>; +using is_receiver_cpo = bool_constant>; #if UNIFEX_CXX_CONCEPTS // Defined the receiver concepts without the macros for improved diagnostics diff --git a/include/unifex/reduce_stream.hpp b/include/unifex/reduce_stream.hpp index 4bb099dec..d45ee07bb 100644 --- a/include/unifex/reduce_stream.hpp +++ b/include/unifex/reduce_stream.hpp @@ -344,7 +344,7 @@ namespace _reduce_cpo { StreamSender&& stream, State&& initialState, ReducerFunc&& reducer) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _reduce::sender, StreamSender, State, ReducerFunc>) -> _reduce::sender { diff --git a/include/unifex/repeat_effect_until.hpp b/include/unifex/repeat_effect_until.hpp index 9c305a608..9140047a9 100644 --- a/include/unifex/repeat_effect_until.hpp +++ b/include/unifex/repeat_effect_until.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ class _rcvr::type { type(type&& other) noexcept : op_(std::exchange(other.op_, {})) {} - + void set_value() noexcept { UNIFEX_ASSERT(op_ != nullptr); @@ -72,7 +73,7 @@ class _rcvr::type { op->isSourceOpConstructed_ = false; op->sourceOp_.destruct(); - if constexpr (std::is_nothrow_invocable_v && is_nothrow_connectable_v && is_nothrow_tag_invocable_v, Receiver>) { + if constexpr (is_nothrow_invocable_v && is_nothrow_connectable_v && is_nothrow_tag_invocable_v, Receiver>) { // call predicate and complete with void if it returns true if(op->predicate_()) { unifex::set_value(std::move(op->receiver_)); @@ -118,16 +119,16 @@ class _rcvr::type { (requires is_receiver_query_cpo_v AND is_callable_v) friend auto tag_invoke(CPO cpo, const type& r) - noexcept(std::is_nothrow_invocable_v) + noexcept(is_nothrow_invocable_v) -> callable_result_t { return std::move(cpo)(r.get_rcvr()); } - + template friend void tag_invoke( tag_t, const type& r, - VisitFunc&& func) noexcept(std::is_nothrow_invocable_v< + VisitFunc&& func) noexcept(is_nothrow_invocable_v< VisitFunc&, const Receiver&>) { std::invoke(func, r.get_rcvr()); @@ -148,9 +149,9 @@ class _op::type { public: template explicit type(Source2&& source, Predicate2&& predicate, Receiver2&& dest) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v && + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v && + is_nothrow_constructible_v && is_nothrow_connectable_v) : source_((Source2&&)source) , predicate_((Predicate2&&)predicate) @@ -203,8 +204,8 @@ class _sndr::type { template explicit type(Source2&& source, Predicate2&& predicate) noexcept( - std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + is_nothrow_constructible_v && + is_nothrow_constructible_v) : source_((Source2&&)source) , predicate_((Predicate2&&)predicate) {} @@ -217,14 +218,14 @@ class _sndr::type { receiver_t>>) friend auto tag_invoke(tag_t, Sender&& s, Receiver&& r) noexcept( - std::is_nothrow_constructible_v(s).source_))> && - std::is_nothrow_constructible_v(s).predicate_))> && - std::is_nothrow_constructible_v, Receiver> && + is_nothrow_constructible_v(s).source_))> && + is_nothrow_constructible_v(s).predicate_))> && + is_nothrow_constructible_v, Receiver> && is_nothrow_connectable_v>>) -> operation_type> { return operation_type>{ - static_cast(s).source_, - static_cast(s).predicate_, + static_cast(s).source_, + static_cast(s).predicate_, (Receiver&&)r }; } @@ -252,9 +253,9 @@ inline const struct repeat_effect_until_cpo { constructible_from, Source> AND constructible_from, Predicate>) auto operator()(Source&& source, Predicate&& predicate) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< repeat_effect_until_sender, std::decay_t>, - Source, + Source, Predicate>) -> repeat_effect_until_sender, std::decay_t> { return repeat_effect_until_sender, std::decay_t>{ @@ -284,7 +285,7 @@ inline const struct repeat_effect_cpo { (requires (!tag_invocable) AND constructible_from, Source>) auto operator()(Source&& source) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< repeat_effect_until_sender, forever>, Source>) -> repeat_effect_until_sender, forever> { diff --git a/include/unifex/retry_when.hpp b/include/unifex/retry_when.hpp index d32d71ce6..1191df32a 100644 --- a/include/unifex/retry_when.hpp +++ b/include/unifex/retry_when.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -135,7 +136,7 @@ class _trigger_receiver::type { friend void tag_invoke( tag_t, const trigger_receiver& r, - VisitFunc&& func) noexcept(std::is_nothrow_invocable_v< + VisitFunc&& func) noexcept(is_nothrow_invocable_v< VisitFunc&, const Receiver&>) { std::invoke(func, r.get_receiver()); @@ -179,7 +180,7 @@ class _source_receiver::type { } template(typename Error) - (requires std::is_invocable_v) + (requires is_invocable_v) void set_error(Error error) noexcept { UNIFEX_ASSERT(op_ != nullptr); auto* const op = op_; @@ -191,7 +192,7 @@ class _source_receiver::type { using trigger_receiver_t = trigger_receiver; using trigger_op_t = unifex::connect_result_t; - if constexpr (std::is_nothrow_invocable_v && + if constexpr (is_nothrow_invocable_v && is_nothrow_connectable_v) { auto& triggerOp = unifex::activate_union_member_with( op->triggerOps_, @@ -229,7 +230,7 @@ class _source_receiver::type { friend void tag_invoke( tag_t, const source_receiver& r, - VisitFunc&& func) noexcept(std::is_nothrow_invocable_v< + VisitFunc&& func) noexcept(is_nothrow_invocable_v< VisitFunc&, const Receiver&>) { std::invoke(func, r.get_receiver()); @@ -250,9 +251,9 @@ class _op::type { public: template explicit type(Source2&& source, Func2&& func, Receiver2&& receiver) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v && + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v && + is_nothrow_constructible_v && is_nothrow_connectable_v) : source_((Source2&&)source) , func_((Func2&&)func) @@ -312,7 +313,7 @@ template using sender = typename _sender, std::decay_t>::type; template -struct sends_done_impl : std::bool_constant::sends_done> {}; +struct sends_done_impl : bool_constant::sends_done> {}; template using any_sends_done = std::disjunction...>; @@ -348,8 +349,8 @@ class _sender::type { template explicit type(Source2&& source, Func2&& func) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v) : source_((Source2&&)source) , func_((Func2&&)func) {} @@ -367,9 +368,9 @@ class _sender::type { sender_to>>) friend auto tag_invoke(tag_t, Self&& self, Receiver&& r) noexcept( - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v, Receiver> && + is_nothrow_constructible_v> && + is_nothrow_constructible_v> && + is_nothrow_constructible_v, Receiver> && is_nothrow_connectable_v>>) -> operation { return operation{ @@ -404,7 +405,7 @@ namespace _retry_when_cpo { constructible_from, Source> AND constructible_from, Func>) auto operator()(Source&& source, Func&& func) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _retry_when::sender, Source, Func>) -> _result_t { return _retry_when::sender{(Source&&)source, (Func&&)func}; diff --git a/include/unifex/scope_guard.hpp b/include/unifex/scope_guard.hpp index 4438f32a7..f2bf13537 100644 --- a/include/unifex/scope_guard.hpp +++ b/include/unifex/scope_guard.hpp @@ -18,6 +18,8 @@ #include #include +#include + #include namespace unifex { @@ -25,7 +27,7 @@ namespace unifex { template struct scope_guard { private: - static_assert(std::is_nothrow_move_constructible_v); + static_assert(is_nothrow_move_constructible_v); UNIFEX_NO_UNIQUE_ADDRESS Func func_; bool released_ = false; diff --git a/include/unifex/sender_concepts.hpp b/include/unifex/sender_concepts.hpp index 17c4e051f..01b74b4d5 100644 --- a/include/unifex/sender_concepts.hpp +++ b/include/unifex/sender_concepts.hpp @@ -73,7 +73,7 @@ namespace detail { UNIFEX_CONCEPT_FRAGMENT( // _has_sender_types_impl, // requires() ( // - typename (std::bool_constant), + typename (bool_constant), typename (_has_value_types), typename (_has_error_types) )); @@ -86,7 +86,7 @@ namespace detail { UNIFEX_CONCEPT_FRAGMENT( // _has_bulk_sender_types_impl, // requires() ( // - typename (std::bool_constant), + typename (bool_constant), typename (_has_value_types), typename (_has_value_types), typename (_has_error_types) @@ -148,7 +148,7 @@ namespace detail { #else template inline constexpr bool _has_sender_traits = - !std::is_base_of_v<_no_sender_traits, sender_traits>; + !is_base_of_v<_no_sender_traits, sender_traits>; #endif template @@ -159,7 +159,7 @@ namespace detail { return _typed_sender_traits{}; } else if constexpr (_is_executor) { return _void_sender_traits{}; - } else if constexpr (std::is_base_of_v) { + } else if constexpr (is_base_of_v) { return sender_base{}; } else { return _no_sender_traits{}; @@ -299,7 +299,7 @@ namespace _connect_cpo { (!_with_member_connect) AND _with_execute) auto operator()(Executor&& e, Receiver&& r) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _as_operation, Executor, Receiver>) -> _result_t { return _as_operation{(Executor &&) e, (Receiver &&) r}; diff --git a/include/unifex/sequence.hpp b/include/unifex/sequence.hpp index b1f9787a0..2bee79e6d 100644 --- a/include/unifex/sequence.hpp +++ b/include/unifex/sequence.hpp @@ -316,8 +316,8 @@ namespace unifex (requires constructible_from AND constructible_from) explicit type(Predecessor2&& predecessor, Successor2&& successor) - noexcept(std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + noexcept(is_nothrow_constructible_v && + is_nothrow_constructible_v) : predecessor_(static_cast(predecessor)) , successor_(static_cast(successor)) {} @@ -371,7 +371,7 @@ namespace unifex // itself. template remove_cvref_t operator()(First&& first) const - noexcept(std::is_nothrow_constructible_v, First>) { + noexcept(is_nothrow_constructible_v, First>) { return static_cast(first); } @@ -389,7 +389,7 @@ namespace unifex (requires sender AND sender AND // (!tag_invocable<_fn, First, Second>)) auto operator()(First&& first, Second&& second) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _seq::sender, First, Second>) diff --git a/include/unifex/span.hpp b/include/unifex/span.hpp index 8d2b4d521..26f5e8a9d 100644 --- a/include/unifex/span.hpp +++ b/include/unifex/span.hpp @@ -64,14 +64,14 @@ struct span { } template(typename U) - (requires (!std::is_const_v) AND same_as) + (requires (!is_const_v) AND same_as) explicit constexpr span(const span& other) noexcept : data_(other.data()) { UNIFEX_ASSERT(other.size() >= Extent); } template(std::size_t OtherExtent, typename U) - (requires (!std::is_const_v) AND same_as) + (requires (!is_const_v) AND same_as) constexpr span(const span& other) noexcept : data_(other.data()) { static_assert( @@ -163,7 +163,7 @@ struct span { template(typename U, std::size_t OtherExtent) (requires same_as || - (!std::is_const_v && same_as)) + (!is_const_v && same_as)) constexpr span(const span& other) noexcept : data_(other.data()), size_(other.size()) {} @@ -296,7 +296,7 @@ span as_bytes(const span& s) noexcept { } template(typename T, std::size_t Extent) - (requires (!std::is_const_v)) + (requires (!is_const_v)) span as_writable_bytes( const span& s) noexcept { constexpr std::size_t maxSize = std::size_t(-1) / sizeof(T); @@ -306,7 +306,7 @@ span as_writable_bytes( } template(typename T) - (requires (!std::is_const_v)) + (requires (!is_const_v)) span as_writable_bytes(const span& s) noexcept { [[maybe_unused]] constexpr std::size_t maxSize = std::size_t(-1) / sizeof(T); UNIFEX_ASSERT(s.size() <= maxSize); diff --git a/include/unifex/std_concepts.hpp b/include/unifex/std_concepts.hpp index b26752154..2cb866fa6 100644 --- a/include/unifex/std_concepts.hpp +++ b/include/unifex/std_concepts.hpp @@ -18,8 +18,8 @@ #include #include #include +#include -#include #include #include @@ -42,7 +42,7 @@ namespace unifex { template UNIFEX_CONCEPT convertible_to = - std::is_convertible_v, To> && + is_convertible_v, To> && UNIFEX_FRAGMENT(unifex::_explicitly_convertible_to, From, To); /// \cond @@ -107,7 +107,7 @@ namespace unifex { template UNIFEX_CONCEPT assignable_from = - std::is_lvalue_reference_v && + is_lvalue_reference_v && UNIFEX_FRAGMENT(unifex::_assignable_from, T, U); template @@ -210,7 +210,7 @@ namespace unifex { template UNIFEX_CONCEPT destructible = - std::is_nothrow_destructible_v; + is_nothrow_destructible_v; template UNIFEX_CONCEPT @@ -253,7 +253,7 @@ namespace unifex { template UNIFEX_CONCEPT movable = - std::is_object_v && + is_object_v && move_constructible && UNIFEX_FRAGMENT(unifex::_move_assignable, T) && swappable; @@ -287,7 +287,7 @@ namespace unifex { template UNIFEX_CONCEPT // invocable = // - std::is_invocable_v; + is_invocable_v; } // namespace unifex diff --git a/include/unifex/stop_immediately.hpp b/include/unifex/stop_immediately.hpp index 17ffb9c37..af885a465 100644 --- a/include/unifex/stop_immediately.hpp +++ b/include/unifex/stop_immediately.hpp @@ -263,7 +263,7 @@ struct _stream::type { } static_assert( - std::is_same_v); + is_same_v); UNIFEX_TRY { stream_.nextOp_.construct_with([&] { diff --git a/include/unifex/stop_token_concepts.hpp b/include/unifex/stop_token_concepts.hpp index 420d7c69f..a13e0fe9b 100644 --- a/include/unifex/stop_token_concepts.hpp +++ b/include/unifex/stop_token_concepts.hpp @@ -17,6 +17,8 @@ #include +#include + #include namespace unifex { @@ -27,12 +29,12 @@ inline constexpr bool is_stop_never_possible_v = false; template inline constexpr bool is_stop_never_possible_v< T, - std::enable_if_t>>> = true; + bool_constant<(T{}.stop_possible())>>>> = true; template -using is_stop_never_possible = std::bool_constant>; +using is_stop_never_possible = bool_constant>; } // namespace unifex diff --git a/include/unifex/stop_when.hpp b/include/unifex/stop_when.hpp index 30cc466b1..2a3af1803 100644 --- a/include/unifex/stop_when.hpp +++ b/include/unifex/stop_when.hpp @@ -177,7 +177,7 @@ namespace unifex Receiver2&& receiver) noexcept(is_nothrow_connectable_v && is_nothrow_connectable_v && - std::is_nothrow_constructible_v) + is_nothrow_constructible_v) : receiver_((Receiver2 &&) receiver) , sourceOp_(unifex::connect((Source &&) source, source_receiver{this})) , triggerOp_( @@ -221,8 +221,8 @@ namespace unifex std::visit( [this](auto&& tuple) { if constexpr ( - std::tuple_size_v< - std::remove_reference_t> != 0) { + std::tuple_size< + std::remove_reference_t>::value != 0) { std::apply( [&](auto set_xxx, auto&&... args) { set_xxx( @@ -309,8 +309,8 @@ namespace unifex template explicit type(Source2&& source, Trigger2&& trigger) noexcept( - std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + is_nothrow_constructible_v && + is_nothrow_constructible_v) : source_((Source2 &&) source) , trigger_((Trigger2 &&) trigger) {} @@ -364,8 +364,8 @@ namespace unifex template(typename Source, typename Trigger) (requires (!tag_invocable<_fn, Source, Trigger>)) auto operator()(Source&& source, Trigger&& trigger) const noexcept( - std::is_nothrow_constructible_v, Source> && - std::is_nothrow_constructible_v, Trigger>) + is_nothrow_constructible_v, Source> && + is_nothrow_constructible_v, Trigger>) -> _stop_when::stop_when_sender< remove_cvref_t, remove_cvref_t> { diff --git a/include/unifex/submit.hpp b/include/unifex/submit.hpp index ad03d6880..19c67104f 100644 --- a/include/unifex/submit.hpp +++ b/include/unifex/submit.hpp @@ -145,7 +145,7 @@ namespace _submit_cpo { tag_invocable<_fn, Sender, Receiver>) void operator()(Sender&& sender, Receiver&& receiver) const { static_assert( - std::is_void_v>, + is_void_v>, "Customisations of submit() must have a void return value"); unifex::tag_invoke(*this, (Sender&&) sender, (Receiver&&) receiver); } diff --git a/include/unifex/tag_invoke.hpp b/include/unifex/tag_invoke.hpp index 3351ca53c..fe91533b0 100644 --- a/include/unifex/tag_invoke.hpp +++ b/include/unifex/tag_invoke.hpp @@ -89,7 +89,7 @@ namespace unifex { {}; template - using is_tag_invocable = std::bool_constant>; + using is_tag_invocable = bool_constant>; template inline constexpr bool is_nothrow_tag_invocable_v = @@ -97,7 +97,7 @@ namespace unifex { template using is_nothrow_tag_invocable = - std::bool_constant>; + bool_constant>; template UNIFEX_CONCEPT tag_invocable = diff --git a/include/unifex/task.hpp b/include/unifex/task.hpp index e42600da9..e31ba0bb9 100644 --- a/include/unifex/task.hpp +++ b/include/unifex/task.hpp @@ -44,11 +44,11 @@ using namespace _util; template using _is_single_valued_tuple = - std::bool_constant<1 >= sizeof...(Types)>; + bool_constant<1 >= sizeof...(Types)>; template using _is_single_valued_variant = - std::bool_constant; + bool_constant; template UNIFEX_CONCEPT_FRAGMENT( // @@ -109,7 +109,7 @@ struct _return_value_or_void { template(typename Value = T) (requires convertible_to AND constructible_from) void return_value(Value&& value) noexcept( - std::is_nothrow_constructible_v) { + is_nothrow_constructible_v) { expected_.reset_value(); unifex::activate_union_member(expected_.value_, (Value &&) value); expected_.state_ = _state::value; @@ -225,7 +225,7 @@ struct _task::type { template class Tuple> using value_types = Variant< typename std::conditional_t< - std::is_void_v, type_list<>, type_list> + is_void_v, type_list<>, type_list> ::template apply>; template< diff --git a/include/unifex/transform.hpp b/include/unifex/transform.hpp index 7212274f2..1f29c57de 100644 --- a/include/unifex/transform.hpp +++ b/include/unifex/transform.hpp @@ -42,7 +42,7 @@ namespace detail { using type = type_list; }; template - struct result_overload>> { + struct result_overload>> { using type = type_list<>; }; } @@ -62,7 +62,7 @@ struct _receiver::type { template void set_value(Values&&... values) && noexcept { using result_type = std::invoke_result_t; - if constexpr (std::is_void_v) { + if constexpr (is_void_v) { if constexpr (noexcept(std::invoke( (Func &&) func_, (Values &&) values...))) { std::invoke((Func &&) func_, (Values &&) values...); @@ -168,8 +168,8 @@ struct _sender::type { sender_to, receiver_t>>) friend auto tag_invoke(tag_t, Sender&& s, Receiver&& r) noexcept( - std::is_nothrow_constructible_v, Receiver> && - std::is_nothrow_constructible_v> && + is_nothrow_constructible_v, Receiver> && + is_nothrow_constructible_v> && is_nothrow_connectable_v, receiver_t>>) -> connect_result_t, receiver_t>> { return unifex::connect( @@ -201,7 +201,7 @@ namespace _tfx_cpo { template(typename Sender, typename Func) (requires (!tag_invocable<_fn, Sender, Func>)) auto operator()(Sender&& predecessor, Func&& func) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< _tfx::sender, Sender, Func>) -> _result_t { return _tfx::sender{(Sender &&) predecessor, (Func &&) func}; diff --git a/include/unifex/transform_done.hpp b/include/unifex/transform_done.hpp index 1121df79a..b898cf70a 100644 --- a/include/unifex/transform_done.hpp +++ b/include/unifex/transform_done.hpp @@ -213,8 +213,8 @@ class _op::type { public: template explicit type(Source&& source, Done2&& done, Receiver2&& dest) - noexcept(std::is_nothrow_move_constructible_v && - std::is_nothrow_move_constructible_v && + noexcept(is_nothrow_move_constructible_v && + is_nothrow_move_constructible_v && is_nothrow_connectable_v) : done_((Done2&&)done) , receiver_((Receiver2&&)dest) @@ -282,8 +282,8 @@ class _sndr::type { template explicit type(Source2&& source, Done2&& done) noexcept( - std::is_nothrow_constructible_v && - std::is_nothrow_constructible_v) + is_nothrow_constructible_v && + is_nothrow_constructible_v) : source_((Source2&&)source) , done_((Done2&&)done) {} @@ -301,8 +301,8 @@ class _sndr::type { friend auto tag_invoke(tag_t, Sender&& s, Receiver&& r) noexcept( is_nothrow_connectable_v, SourceReceiver> && - std::is_nothrow_constructible_v> && - std::is_nothrow_constructible_v, Receiver>) + is_nothrow_constructible_v> && + is_nothrow_constructible_v, Receiver>) -> operation_type, Done, Receiver> { return operation_type, Done, Receiver>{ static_cast(s).source_, @@ -336,7 +336,7 @@ inline const struct transform_done_cpo { constructible_from, Done> AND callable>) auto operator()(Source&& source, Done&& done) const - noexcept(std::is_nothrow_constructible_v< + noexcept(is_nothrow_constructible_v< transform_done_sender, Source, Done>) diff --git a/include/unifex/type_index.hpp b/include/unifex/type_index.hpp index 7d88737ec..224d357ea 100644 --- a/include/unifex/type_index.hpp +++ b/include/unifex/type_index.hpp @@ -74,7 +74,7 @@ struct type_index final { template static type_index make() noexcept { - static_assert(std::is_same_v>); + static_assert(is_same_v>); #ifdef __FUNCSIG__ static constexpr auto index = __FUNCSIG__; diff --git a/include/unifex/type_traits.hpp b/include/unifex/type_traits.hpp index 88ff465f7..1e74e8d51 100644 --- a/include/unifex/type_traits.hpp +++ b/include/unifex/type_traits.hpp @@ -21,19 +21,12 @@ #include -#if (defined(__cpp_lib_type_trait_variable_templates) && \ - __cpp_lib_type_trait_variable_templates > 0) -#define UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES 1 -#else -#define UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES 0 -#endif - #if defined(__clang__) #define UNIFEX_IS_SAME(...) __is_same(__VA_ARGS__) #elif defined(__GNUC__) && __GNUC__ >= 6 #define UNIFEX_IS_SAME(...) __is_same_as(__VA_ARGS__) #elif UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES -#define UNIFEX_IS_SAME(...) std::is_same_v<__VA_ARGS__> +#define UNIFEX_IS_SAME(...) is_same_v<__VA_ARGS__> #else #define UNIFEX_IS_SAME(...) std::is_same<__VA_ARGS__>::value #endif @@ -41,7 +34,7 @@ #if defined(__GNUC__) || defined(_MSC_VER) #define UNIFEX_IS_BASE_OF(...) __is_base_of(__VA_ARGS__) #elif UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES -#define UNIFEX_IS_BASE_OF(...) std::is_base_of_v<__VA_ARGS__> +#define UNIFEX_IS_BASE_OF(...) is_base_of_v<__VA_ARGS__> #else #define UNIFEX_IS_BASE_OF(...) std::is_base_of<__VA_ARGS__>::value #endif @@ -50,7 +43,7 @@ (defined(__GNUC__) && __GNUC__ >= 8) #define UNIFEX_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__) #elif UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES -#define UNIFEX_IS_CONSTRUCTIBLE(...) std::is_constructible_v<__VA_ARGS__> +#define UNIFEX_IS_CONSTRUCTIBLE(...) is_constructible_v<__VA_ARGS__> #else #define UNIFEX_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value #endif @@ -59,6 +52,69 @@ namespace unifex { +#if UNIFEX_CXX_TRAIT_VARIABLE_TEMPLATES + +using std::is_same_v; +using std::is_void_v; +using std::is_const_v; +using std::is_empty_v; +using std::is_object_v; +using std::is_base_of_v; +using std::is_invocable_v; +using std::is_reference_v; +using std::is_convertible_v; +using std::is_lvalue_reference_v; +using std::is_nothrow_invocable_v; +using std::is_nothrow_destructible_v; +using std::is_nothrow_constructible_v; +using std::is_nothrow_copy_constructible_v; +using std::is_nothrow_move_constructible_v; + +#else + +template +inline constexpr bool is_same_v = false; +template +inline constexpr bool is_same_v = true; +template +inline constexpr bool is_void_v = std::is_void::value; +template +inline constexpr bool is_const_v = std::is_const::value; +template +inline constexpr bool is_empty_v = std::is_empty::value; +template +inline constexpr bool is_object_v = std::is_object::value; +template +inline constexpr bool is_base_of_v = std::is_base_of::value; +template +inline constexpr bool is_invocable_v = std::is_invocable::value; +template +inline constexpr bool is_reference_v = std::is_reference::value; +template +inline constexpr bool is_convertible_v = std::is_convertible::value; +template +inline constexpr bool is_lvalue_reference_v = std::is_lvalue_reference::value; +template +inline constexpr bool is_nothrow_invocable_v = std::is_nothrow_invocable::value; +template +inline constexpr bool is_nothrow_destructible_v = std::is_nothrow_destructible::value; +template +inline constexpr bool is_nothrow_constructible_v = std::is_nothrow_constructible::value; +template +inline constexpr bool is_nothrow_copy_constructible_v = std::is_nothrow_copy_constructible::value; +template +inline constexpr bool is_nothrow_move_constructible_v = std::is_nothrow_move_constructible::value; + +#endif + +#if defined(__cpp_lib_bool_constant) && \ + __cpp_lib_bool_constant > 0 +using std::bool_constant; +#else +template +using bool_constant = std::integral_constant; +#endif + namespace _ti { template struct type_identity { @@ -105,7 +161,7 @@ template