From 9aedaad2c45be1d6e00fa61dd90d88a1d5ffb8d8 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Feb 2024 09:22:31 -0800 Subject: [PATCH 1/5] fix some problems found by clang-tidy --- include/exec/__detail/__manual_lifetime.hpp | 2 ++ include/exec/__detail/__sender_facade.hpp | 15 ++++++++------- include/exec/async_scope.hpp | 2 +- .../exec/linux/__detail/memory_mapped_region.hpp | 2 ++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/exec/__detail/__manual_lifetime.hpp b/include/exec/__detail/__manual_lifetime.hpp index ac00c8839..0d86d175e 100644 --- a/include/exec/__detail/__manual_lifetime.hpp +++ b/include/exec/__detail/__manual_lifetime.hpp @@ -16,6 +16,8 @@ */ #pragma once +#include "../../stdexec/concepts.hpp" + #include #include #include diff --git a/include/exec/__detail/__sender_facade.hpp b/include/exec/__detail/__sender_facade.hpp index f80375372..98d90a64d 100644 --- a/include/exec/__detail/__sender_facade.hpp +++ b/include/exec/__detail/__sender_facade.hpp @@ -303,20 +303,20 @@ namespace exec { if constexpr (__mvalid<__pre_completions_t, _NewSender, _NewEnv>) { using _Completions = __completions_t<_NewEnv, __pre_completions_t<_NewSender, _NewEnv>>; - if constexpr (__valid_completion_signatures<_Completions, _Env>) { - return (_Completions(*)()) nullptr; + if constexpr (__valid_completion_signatures<_Completions>) { + return static_cast<_Completions(*)()>(nullptr); } else { // assume this is an error message and return it directly - return (_Completions(*)()) nullptr; + return static_cast<_Completions(*)()>(nullptr); } } else { - return (__diagnostic_t<_Env>(*)()) nullptr; + return static_cast<__diagnostic_t<_Env>(*)()>(nullptr); } } else if constexpr (same_as<_NewSender, __sender_transform_failed>) { - return (__diagnostic_t<_Env>(*)()) nullptr; + return static_cast<__diagnostic_t<_Env>(*)()>(nullptr); } else { // assume this is an error message and return it directly - return (_NewSender(*)()) nullptr; + return static_cast<_NewSender(*)()>(nullptr); } } @@ -338,7 +338,8 @@ namespace exec { } // namespace __stl template - using __sender_facade = __stl::__sender<_DerivedId, _Sender, _Kernel>; + using __sender_facade [[deprecated]] = + __stl::__sender<_DerivedId, _Sender, _Kernel>; struct __default_kernel { struct __no_data { }; diff --git a/include/exec/async_scope.hpp b/include/exec/async_scope.hpp index 54bb631ba..5c84908a2 100644 --- a/include/exec/async_scope.hpp +++ b/include/exec/async_scope.hpp @@ -626,7 +626,7 @@ namespace exec { -> __completions_t<_Self> { return {}; } - + friend empty_env tag_invoke(get_env_t, const __t&) noexcept { return {}; } diff --git a/include/exec/linux/__detail/memory_mapped_region.hpp b/include/exec/linux/__detail/memory_mapped_region.hpp index cd0659a3c..a63b94184 100644 --- a/include/exec/linux/__detail/memory_mapped_region.hpp +++ b/include/exec/linux/__detail/memory_mapped_region.hpp @@ -16,6 +16,8 @@ */ #pragma once +#include "../memory_mapped_region.hpp" + #include #include #include From 3eaba4111bc8e8516ed1a4f516d753503b87e504 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Feb 2024 09:31:38 -0800 Subject: [PATCH 2/5] clang-modernize --- .../__detail/__atomic_intrusive_queue.hpp | 12 +- include/exec/__detail/__basic_sequence.hpp | 2 +- include/exec/__detail/__bwos_lifo_queue.hpp | 106 +++++---- include/exec/__detail/__manual_lifetime.hpp | 18 +- include/exec/__detail/__numa.hpp | 30 +-- include/exec/__detail/__sender_facade.hpp | 27 ++- include/exec/__detail/__xorshift.hpp | 8 +- include/exec/any_sender_of.hpp | 109 +++++---- include/exec/async_scope.hpp | 45 ++-- include/exec/at_coroutine_exit.hpp | 45 ++-- include/exec/create.hpp | 2 +- include/exec/env.hpp | 4 +- include/exec/finally.hpp | 8 +- .../linux/__detail/memory_mapped_region.hpp | 8 +- .../linux/__detail/safe_file_descriptor.hpp | 6 +- include/exec/linux/io_uring_context.hpp | 126 ++++++----- include/exec/linux/memory_mapped_region.hpp | 10 +- include/exec/linux/safe_file_descriptor.hpp | 7 +- include/exec/materialize.hpp | 24 +- include/exec/on_coro_disposition.hpp | 40 ++-- include/exec/repeat_effect_until.hpp | 2 +- include/exec/repeat_n.hpp | 2 +- include/exec/reschedule.hpp | 4 +- include/exec/sequence/any_sequence_of.hpp | 32 +-- include/exec/sequence/empty_sequence.hpp | 2 +- include/exec/sequence/ignore_all_values.hpp | 11 +- include/exec/sequence/iterate.hpp | 4 +- include/exec/sequence/transform_each.hpp | 11 +- include/exec/sequence_senders.hpp | 6 +- include/exec/single_thread_context.hpp | 3 +- include/exec/static_thread_pool.hpp | 150 +++++++------ include/exec/task.hpp | 48 ++-- include/exec/trampoline_scheduler.hpp | 17 +- include/exec/variant_sender.hpp | 21 +- include/exec/when_any.hpp | 14 +- include/stdexec/__detail/__basic_sender.hpp | 10 +- include/stdexec/__detail/__config.hpp | 9 +- include/stdexec/__detail/__domain.hpp | 8 +- include/stdexec/__detail/__env.hpp | 56 ++--- include/stdexec/__detail/__intrusive_ptr.hpp | 33 +-- .../stdexec/__detail/__intrusive_queue.hpp | 32 +-- include/stdexec/__detail/__meta.hpp | 36 +-- include/stdexec/__detail/__type_traits.hpp | 4 +- include/stdexec/coroutine.hpp | 6 +- include/stdexec/execution.hpp | 209 +++++++++--------- include/stdexec/functional.hpp | 2 +- include/stdexec/stop_token.hpp | 44 ++-- include/tbbexec/tbb_thread_pool.hpp | 60 ++--- 48 files changed, 776 insertions(+), 697 deletions(-) diff --git a/include/exec/__detail/__atomic_intrusive_queue.hpp b/include/exec/__detail/__atomic_intrusive_queue.hpp index 9d49c6a82..90da95ef9 100644 --- a/include/exec/__detail/__atomic_intrusive_queue.hpp +++ b/include/exec/__detail/__atomic_intrusive_queue.hpp @@ -31,7 +31,7 @@ namespace exec { using __atomic_node_pointer = std::atomic<_Tp *>; [[nodiscard]] - bool empty() const noexcept { + auto empty() const noexcept -> bool { return __head_.load(std::memory_order_relaxed) == nullptr; } @@ -40,7 +40,7 @@ namespace exec { bool __was_empty; }; - try_push_result try_push_front(__node_pointer t) noexcept { + auto try_push_front(__node_pointer t) noexcept -> try_push_result { __node_pointer __old_head = __head_.load(std::memory_order_relaxed); t->*_NextPtr = __old_head; return { @@ -48,7 +48,7 @@ namespace exec { __old_head == nullptr}; } - bool push_front(__node_pointer t) noexcept { + auto push_front(__node_pointer t) noexcept -> bool { __node_pointer __old_head = __head_.load(std::memory_order_relaxed); do { t->*_NextPtr = __old_head; @@ -67,16 +67,16 @@ namespace exec { queue.clear(); } - stdexec::__intrusive_queue<_NextPtr> pop_all() noexcept { + auto pop_all() noexcept -> stdexec::__intrusive_queue<_NextPtr> { return stdexec::__intrusive_queue<_NextPtr>::make(reset_head()); } - stdexec::__intrusive_queue<_NextPtr> pop_all_reversed() noexcept { + auto pop_all_reversed() noexcept -> stdexec::__intrusive_queue<_NextPtr> { return stdexec::__intrusive_queue<_NextPtr>::make_reversed(reset_head()); } private: - __node_pointer reset_head() noexcept { + auto reset_head() noexcept -> __node_pointer { __node_pointer __old_head = __head_.load(std::memory_order_relaxed); while (!__head_.compare_exchange_weak(__old_head, nullptr, std::memory_order_acq_rel)) { ; diff --git a/include/exec/__detail/__basic_sequence.hpp b/include/exec/__detail/__basic_sequence.hpp index 94aad4914..8f26c69a9 100644 --- a/include/exec/__detail/__basic_sequence.hpp +++ b/include/exec/__detail/__basic_sequence.hpp @@ -41,7 +41,7 @@ namespace exec { using __captures_t = stdexec::__minvoke<__desc_t, stdexec::__q>; - static __tag_t __tag() noexcept { + static auto __tag() noexcept -> __tag_t { return {}; } diff --git a/include/exec/__detail/__bwos_lifo_queue.hpp b/include/exec/__detail/__bwos_lifo_queue.hpp index 1bea1b71f..9b9ad7e88 100644 --- a/include/exec/__detail/__bwos_lifo_queue.hpp +++ b/include/exec/__detail/__bwos_lifo_queue.hpp @@ -102,20 +102,24 @@ namespace exec::bwos { std::size_t block_size, Allocator allocator = Allocator()); - Tp pop_back() noexcept; + auto pop_back() noexcept -> Tp; - Tp steal_front() noexcept; + auto steal_front() noexcept -> Tp; - bool push_back(Tp value) noexcept; + auto push_back(Tp value) noexcept -> bool; template - Iterator push_back(Iterator first, Sentinel last) noexcept; + auto push_back(Iterator first, Sentinel last) noexcept -> Iterator; - std::size_t get_available_capacity() const noexcept; - std::size_t get_free_capacity() const noexcept; + [[nodiscard]] + auto get_available_capacity() const noexcept -> std::size_t; + [[nodiscard]] + auto get_free_capacity() const noexcept -> std::size_t; - std::size_t block_size() const noexcept; - std::size_t num_blocks() const noexcept; + [[nodiscard]] + auto block_size() const noexcept -> std::size_t; + [[nodiscard]] + auto num_blocks() const noexcept -> std::size_t; private: template @@ -125,32 +129,36 @@ namespace exec::bwos { explicit block_type(std::size_t block_size, Allocator allocator = Allocator()); block_type(const block_type &); - block_type &operator=(const block_type &); + auto operator=(const block_type &) -> block_type &; block_type(block_type &&) noexcept; - block_type &operator=(block_type &&) noexcept; + auto operator=(block_type &&) noexcept -> block_type &; - lifo_queue_error_code put(Tp value) noexcept; + auto put(Tp value) noexcept -> lifo_queue_error_code; template - Iterator bulk_put(Iterator first, Sentinel last) noexcept; + auto bulk_put(Iterator first, Sentinel last) noexcept -> Iterator; - fetch_result get() noexcept; + auto get() noexcept -> fetch_result; - fetch_result steal() noexcept; + auto steal() noexcept -> fetch_result; - takeover_result takeover() noexcept; - bool is_writable() const noexcept; + auto takeover() noexcept -> takeover_result; + [[nodiscard]] + auto is_writable() const noexcept -> bool; - std::size_t free_capacity() const noexcept; + [[nodiscard]] + auto free_capacity() const noexcept -> std::size_t; void grant() noexcept; - bool reclaim() noexcept; + auto reclaim() noexcept -> bool; - bool is_stealable() const noexcept; + [[nodiscard]] + auto is_stealable() const noexcept -> bool; - std::size_t block_size() const noexcept; + [[nodiscard]] + auto block_size() const noexcept -> std::size_t; alignas(hardware_destructive_interference_size) std::atomic head_{}; alignas(hardware_destructive_interference_size) std::atomic tail_{}; @@ -159,9 +167,9 @@ namespace exec::bwos { std::vector ring_buffer_; }; - bool advance_get_index() noexcept; - bool advance_steal_index(std::size_t expected_thief_counter) noexcept; - bool advance_put_index() noexcept; + auto advance_get_index() noexcept -> bool; + auto advance_steal_index(std::size_t expected_thief_counter) noexcept -> bool; + auto advance_put_index() noexcept -> bool; alignas(hardware_destructive_interference_size) std::atomic owner_block_{1}; alignas(hardware_destructive_interference_size) std::atomic thief_block_{0}; @@ -186,7 +194,7 @@ namespace exec::bwos { } template - Tp lifo_queue::pop_back() noexcept { + auto lifo_queue::pop_back() noexcept -> Tp { do { std::size_t owner_index = owner_block_.load(std::memory_order_relaxed) & mask_; block_type ¤t_block = blocks_[owner_index]; @@ -202,7 +210,7 @@ namespace exec::bwos { } template - Tp lifo_queue::steal_front() noexcept { + auto lifo_queue::steal_front() noexcept -> Tp { std::size_t thief = 0; do { thief = thief_block_.load(std::memory_order_relaxed); @@ -223,7 +231,7 @@ namespace exec::bwos { } template - bool lifo_queue::push_back(Tp value) noexcept { + auto lifo_queue::push_back(Tp value) noexcept -> bool { do { std::size_t owner_index = owner_block_.load(std::memory_order_relaxed) & mask_; block_type ¤t_block = blocks_[owner_index]; @@ -237,7 +245,7 @@ namespace exec::bwos { template template - Iterator lifo_queue::push_back(Iterator first, Sentinel last) noexcept { + auto lifo_queue::push_back(Iterator first, Sentinel last) noexcept -> Iterator { do { std::size_t owner_index = owner_block_.load(std::memory_order_relaxed) & mask_; block_type ¤t_block = blocks_[owner_index]; @@ -247,7 +255,7 @@ namespace exec::bwos { } template - std::size_t lifo_queue::get_free_capacity() const noexcept { + auto lifo_queue::get_free_capacity() const noexcept -> std::size_t { std::size_t owner_counter = owner_block_.load(std::memory_order_relaxed); std::size_t owner_index = owner_counter & mask_; std::size_t local_capacity = blocks_[owner_index].free_capacity(); @@ -258,22 +266,22 @@ namespace exec::bwos { } template - std::size_t lifo_queue::get_available_capacity() const noexcept { + auto lifo_queue::get_available_capacity() const noexcept -> std::size_t { return num_blocks() * block_size(); } template - std::size_t lifo_queue::block_size() const noexcept { + auto lifo_queue::block_size() const noexcept -> std::size_t { return blocks_[0].block_size(); } template - std::size_t lifo_queue::num_blocks() const noexcept { + auto lifo_queue::num_blocks() const noexcept -> std::size_t { return blocks_.size(); } template - bool lifo_queue::advance_get_index() noexcept { + auto lifo_queue::advance_get_index() noexcept -> bool { std::size_t owner_counter = owner_block_.load(std::memory_order_relaxed); std::size_t predecessor = owner_counter - 1ul; std::size_t predecessor_index = predecessor & mask_; @@ -293,7 +301,7 @@ namespace exec::bwos { } template - bool lifo_queue::advance_put_index() noexcept { + auto lifo_queue::advance_put_index() noexcept -> bool { std::size_t owner_counter = owner_block_.load(std::memory_order_relaxed); std::size_t next_counter = owner_counter + 1ul; std::size_t thief_counter = thief_block_.load(std::memory_order_relaxed); @@ -315,7 +323,8 @@ namespace exec::bwos { } template - bool lifo_queue::advance_steal_index(std::size_t expected_thief_counter) noexcept { + auto lifo_queue::advance_steal_index(std::size_t expected_thief_counter) noexcept + -> bool { std::size_t thief_counter = expected_thief_counter; std::size_t next_counter = thief_counter + 1; std::size_t next_index = next_counter & mask_; @@ -349,8 +358,8 @@ namespace exec::bwos { } template - typename lifo_queue::block_type & - lifo_queue::block_type::operator=(const block_type &other) { + auto lifo_queue::block_type::operator=(const block_type &other) -> + typename lifo_queue::block_type & { head_.store(other.head_.load(std::memory_order_relaxed), std::memory_order_relaxed); tail_.store(other.tail_.load(std::memory_order_relaxed), std::memory_order_relaxed); steal_tail_.store(other.steal_tail_.load(std::memory_order_relaxed), std::memory_order_relaxed); @@ -369,8 +378,8 @@ namespace exec::bwos { } template - typename lifo_queue::block_type & - lifo_queue::block_type::operator=(block_type &&other) noexcept { + auto lifo_queue::block_type::operator=(block_type &&other) noexcept -> + typename lifo_queue::block_type & { head_.store(other.head_.load(std::memory_order_relaxed), std::memory_order_relaxed); tail_.store(other.tail_.load(std::memory_order_relaxed), std::memory_order_relaxed); steal_tail_.store(other.steal_tail_.load(std::memory_order_relaxed), std::memory_order_relaxed); @@ -380,7 +389,7 @@ namespace exec::bwos { } template - lifo_queue_error_code lifo_queue::block_type::put(Tp value) noexcept { + auto lifo_queue::block_type::put(Tp value) noexcept -> lifo_queue_error_code { std::uint64_t back = tail_.load(std::memory_order_relaxed); if (back < block_size()) [[likely]] { ring_buffer_[back] = static_cast(value); @@ -392,7 +401,8 @@ namespace exec::bwos { template template - Iterator lifo_queue::block_type::bulk_put(Iterator first, Sentinel last) noexcept { + auto lifo_queue::block_type::bulk_put(Iterator first, Sentinel last) noexcept + -> Iterator { std::uint64_t back = tail_.load(std::memory_order_relaxed); while (first != last && back < block_size()) { ring_buffer_[back] = static_cast(*first); @@ -404,7 +414,7 @@ namespace exec::bwos { } template - fetch_result lifo_queue::block_type::get() noexcept { + auto lifo_queue::block_type::get() noexcept -> fetch_result { std::uint64_t front = head_.load(std::memory_order_relaxed); if (front == block_size()) [[unlikely]] { return {lifo_queue_error_code::done, nullptr}; @@ -419,7 +429,7 @@ namespace exec::bwos { } template - fetch_result lifo_queue::block_type::steal() noexcept { + auto lifo_queue::block_type::steal() noexcept -> fetch_result { std::uint64_t spos = steal_tail_.load(std::memory_order_relaxed); fetch_result result{}; if (spos == block_size()) [[unlikely]] { @@ -442,7 +452,7 @@ namespace exec::bwos { } template - takeover_result lifo_queue::block_type::takeover() noexcept { + auto lifo_queue::block_type::takeover() noexcept -> takeover_result { std::uint64_t spos = steal_tail_.exchange(block_size(), std::memory_order_relaxed); if (spos == block_size()) [[unlikely]] { return {head_.load(std::memory_order_relaxed), tail_.load(std::memory_order_relaxed)}; @@ -452,20 +462,20 @@ namespace exec::bwos { } template - bool lifo_queue::block_type::is_writable() const noexcept { + auto lifo_queue::block_type::is_writable() const noexcept -> bool { std::uint64_t expected_steal = block_size(); std::uint64_t spos = steal_tail_.load(std::memory_order_relaxed); return spos == expected_steal; } template - std::size_t lifo_queue::block_type::free_capacity() const noexcept { + auto lifo_queue::block_type::free_capacity() const noexcept -> std::size_t { std::uint64_t back = tail_.load(std::memory_order_relaxed); return block_size() - back; } template - bool lifo_queue::block_type::reclaim() noexcept { + auto lifo_queue::block_type::reclaim() noexcept -> bool { std::uint64_t expected_steal_head_ = tail_.load(std::memory_order_relaxed); while (steal_head_.load(std::memory_order_acquire) != expected_steal_head_) { spin_loop_pause(); @@ -478,7 +488,7 @@ namespace exec::bwos { } template - std::size_t lifo_queue::block_type::block_size() const noexcept { + auto lifo_queue::block_type::block_size() const noexcept -> std::size_t { return ring_buffer_.size(); } @@ -489,7 +499,7 @@ namespace exec::bwos { } template - bool lifo_queue::block_type::is_stealable() const noexcept { + auto lifo_queue::block_type::is_stealable() const noexcept -> bool { return steal_tail_.load(std::memory_order_acquire) != block_size(); } } // namespace exec::bwos \ No newline at end of file diff --git a/include/exec/__detail/__manual_lifetime.hpp b/include/exec/__detail/__manual_lifetime.hpp index 0d86d175e..989eba93b 100644 --- a/include/exec/__detail/__manual_lifetime.hpp +++ b/include/exec/__detail/__manual_lifetime.hpp @@ -34,20 +34,20 @@ namespace exec { } __manual_lifetime(const __manual_lifetime&) = delete; - __manual_lifetime& operator=(const __manual_lifetime&) = delete; + auto operator=(const __manual_lifetime&) -> __manual_lifetime& = delete; __manual_lifetime(__manual_lifetime&&) = delete; - __manual_lifetime& operator=(__manual_lifetime&&) = delete; + auto operator=(__manual_lifetime&&) -> __manual_lifetime& = delete; template - _Ty& __construct(_Args&&... __args) noexcept( - stdexec::__nothrow_constructible_from<_Ty, _Args...>) { + auto __construct(_Args&&... __args) noexcept( + stdexec::__nothrow_constructible_from<_Ty, _Args...>) -> _Ty& { return *::new (static_cast(std::addressof(__value_))) _Ty(static_cast<_Args&&>(__args)...); } template - _Ty& __construct_with(_Func&& func) { + auto __construct_with(_Func&& func) -> _Ty& { return *::new (static_cast(std::addressof(__value_))) _Ty((static_cast<_Func&&>(func))()); } @@ -56,19 +56,19 @@ namespace exec { __value_.~_Ty(); } - _Ty& __get() & noexcept { + auto __get() & noexcept -> _Ty& { return __value_; } - _Ty&& __get() && noexcept { + auto __get() && noexcept -> _Ty&& { return static_cast<_Ty&&>(__value_); } - const _Ty& __get() const & noexcept { + auto __get() const & noexcept -> const _Ty& { return __value_; } - const _Ty&& __get() const && noexcept { + auto __get() const && noexcept -> const _Ty&& { return static_cast(__value_); } diff --git a/include/exec/__detail/__numa.hpp b/include/exec/__detail/__numa.hpp index afe7edd76..c28f73fe8 100644 --- a/include/exec/__detail/__numa.hpp +++ b/include/exec/__detail/__numa.hpp @@ -26,29 +26,29 @@ namespace exec { struct numa_policy { virtual ~numa_policy() = default; - virtual std::size_t num_nodes() = 0; - virtual std::size_t num_cpus(int node) = 0; - virtual int bind_to_node(int node) = 0; - virtual int thread_index_to_node(std::size_t index) = 0; + virtual auto num_nodes() -> std::size_t = 0; + virtual auto num_cpus(int node) -> std::size_t = 0; + virtual auto bind_to_node(int node) -> int = 0; + virtual auto thread_index_to_node(std::size_t index) -> int = 0; }; class no_numa_policy : public numa_policy { public: no_numa_policy() noexcept = default; - std::size_t num_nodes() override { + auto num_nodes() -> std::size_t override { return 1; } - std::size_t num_cpus(int node) override { + auto num_cpus(int node) -> std::size_t override { return std::thread::hardware_concurrency(); } - int bind_to_node(int node) override { + auto bind_to_node(int node) -> int override { return 0; } - int thread_index_to_node(std::size_t index) override { + auto thread_index_to_node(std::size_t index) -> int override { return 0; } }; @@ -215,7 +215,7 @@ namespace exec { namespace exec { using default_numa_policy = no_numa_policy; - inline numa_policy* get_numa_policy() noexcept { + inline auto get_numa_policy() noexcept -> numa_policy* { thread_local default_numa_policy g_default_numa_policy{}; return &g_default_numa_policy; } @@ -233,7 +233,7 @@ namespace exec { explicit numa_allocator(const numa_allocator&) noexcept { } - T* allocate(std::size_t n) { + auto allocate(std::size_t n) -> T* { std::allocator alloc{}; return alloc.allocate(n); } @@ -243,11 +243,11 @@ namespace exec { alloc.deallocate(p, n); } - friend bool operator==(const numa_allocator&, const numa_allocator&) noexcept = default; + friend auto operator==(const numa_allocator&, const numa_allocator&) noexcept -> bool = default; }; class nodemask { - static nodemask make_any() noexcept { + static auto make_any() noexcept -> nodemask { nodemask mask; mask.mask_ = true; return mask; @@ -256,12 +256,12 @@ namespace exec { public: nodemask() noexcept = default; - static const nodemask& any() noexcept { + static auto any() noexcept -> const nodemask& { static nodemask mask = make_any(); return mask; } - bool operator[](std::size_t nodemask) const noexcept { + auto operator[](std::size_t nodemask) const noexcept -> bool { return mask_ && nodemask == 0; } @@ -269,7 +269,7 @@ namespace exec { mask_ |= nodemask == 0; } - friend bool operator==(const nodemask& lhs, const nodemask& rhs) noexcept { + friend auto operator==(const nodemask& lhs, const nodemask& rhs) noexcept -> bool { return lhs.mask_ == rhs.mask_; } diff --git a/include/exec/__detail/__sender_facade.hpp b/include/exec/__detail/__sender_facade.hpp index 98d90a64d..49e36c58a 100644 --- a/include/exec/__detail/__sender_facade.hpp +++ b/include/exec/__detail/__sender_facade.hpp @@ -59,7 +59,7 @@ namespace exec { template _Self> [[noreturn]] - friend _Env tag_invoke(get_env_t, _Self) noexcept { + friend auto tag_invoke(get_env_t, _Self) noexcept -> _Env { static_assert( __never_true<_Self>, "we should never be instantiating the body of this function"); std::terminate(); @@ -240,7 +240,7 @@ namespace exec { }; template - __minvoke<__id_<>, _Self> __is_derived_sender_(const _Self&); + auto __is_derived_sender_(const _Self&) -> __minvoke<__id_<>, _Self>; template concept __is_derived_sender = // @@ -304,19 +304,19 @@ namespace exec { using _Completions = __completions_t<_NewEnv, __pre_completions_t<_NewSender, _NewEnv>>; if constexpr (__valid_completion_signatures<_Completions>) { - return static_cast<_Completions(*)()>(nullptr); + return static_cast<_Completions (*)()>(nullptr); } else { // assume this is an error message and return it directly - return static_cast<_Completions(*)()>(nullptr); + return static_cast<_Completions (*)()>(nullptr); } } else { - return static_cast<__diagnostic_t<_Env>(*)()>(nullptr); + return static_cast<__diagnostic_t<_Env> (*)()>(nullptr); } } else if constexpr (same_as<_NewSender, __sender_transform_failed>) { - return static_cast<__diagnostic_t<_Env>(*)()>(nullptr); + return static_cast<__diagnostic_t<_Env> (*)()>(nullptr); } else { // assume this is an error message and return it directly - return static_cast<_NewSender(*)()>(nullptr); + return static_cast<_NewSender (*)()>(nullptr); } } @@ -338,29 +338,28 @@ namespace exec { } // namespace __stl template - using __sender_facade [[deprecated]] = - __stl::__sender<_DerivedId, _Sender, _Kernel>; + using __sender_facade [[deprecated]] = __stl::__sender<_DerivedId, _Sender, _Kernel>; struct __default_kernel { struct __no_data { }; template - static _Sender&& transform_sender( // + static auto transform_sender( // _Sender&& __sndr, // [[maybe_unused]] stdexec::__ignore __data, // - [[maybe_unused]] stdexec::__ignore __rcvr) noexcept { + [[maybe_unused]] stdexec::__ignore __rcvr) noexcept -> _Sender&& { return static_cast<_Sender&&>(__sndr); } template - static _Env get_env(_Env&& __env) noexcept { + static auto get_env(_Env&& __env) noexcept -> _Env { static_assert(stdexec::__nothrow_move_constructible<_Env>); return static_cast<_Env&&>(__env); } - static __no_data get_data( // + static auto get_data( // [[maybe_unused]] stdexec::__ignore __rcvr, // - [[maybe_unused]] void* __compl_sigs) noexcept { + [[maybe_unused]] void* __compl_sigs) noexcept -> __no_data { return {}; } diff --git a/include/exec/__detail/__xorshift.hpp b/include/exec/__detail/__xorshift.hpp index 17134574d..3d0c534d1 100644 --- a/include/exec/__detail/__xorshift.hpp +++ b/include/exec/__detail/__xorshift.hpp @@ -30,15 +30,15 @@ namespace exec { public: using result_type = std::uint32_t; - static constexpr result_type(min)() { + static constexpr auto(min)() -> result_type { return 0; } - static constexpr result_type(max)() { + static constexpr auto(max)() -> result_type { return UINT32_MAX; } - friend bool operator==(xorshift const &, xorshift const &) = default; + friend auto operator==(xorshift const &, xorshift const &) -> bool = default; xorshift() : m_seed(0xc1f651c67c62c6e0ull) { @@ -56,7 +56,7 @@ namespace exec { m_seed = std::uint64_t(rd()) << 31 | std::uint64_t(rd()); } - result_type operator()() { + auto operator()() -> result_type { std::uint64_t result = m_seed * 0xd989bcacc137dcd5ull; m_seed ^= m_seed >> 11; m_seed ^= m_seed << 31; diff --git a/include/exec/any_sender_of.hpp b/include/exec/any_sender_of.hpp index 51fc3bee2..253bdfebc 100644 --- a/include/exec/any_sender_of.hpp +++ b/include/exec/any_sender_of.hpp @@ -31,7 +31,7 @@ namespace exec { struct __create_vtable_t { template requires __tag_invocable_r, __mtype<_Tp>> - constexpr const _VTable* operator()(__mtype<_VTable>, __mtype<_Tp>) const noexcept { + constexpr auto operator()(__mtype<_VTable>, __mtype<_Tp>) const noexcept -> const _VTable* { return stdexec::tag_invoke(__create_vtable_t{}, __mtype<_VTable>{}, __mtype<_Tp>{}); } }; @@ -45,7 +45,7 @@ namespace exec { struct __query_vfun<_Tag (*const)(_Ret (*)(_As...))> { _Ret (*__fn_)(void*, _As...); - _Ret operator()(_Tag, void* __rcvr, _As&&... __as) const { + auto operator()(_Tag, void* __rcvr, _As&&... __as) const -> _Ret { return __fn_(__rcvr, static_cast<_As&&>(__as)...); } }; @@ -54,7 +54,7 @@ namespace exec { struct __query_vfun<_Tag (*)(_Ret (*)(_As...))> { _Ret (*__fn_)(void*, _As...); - _Ret operator()(_Tag, void* __rcvr, _As&&... __as) const { + auto operator()(_Tag, void* __rcvr, _As&&... __as) const -> _Ret { return __fn_(__rcvr, static_cast<_As&&>(__as)...); } }; @@ -63,7 +63,7 @@ namespace exec { struct __query_vfun<_Tag (*const)(_Ret (*)(_As...) noexcept)> { _Ret (*__fn_)(void*, _As...) noexcept; - _Ret operator()(_Tag, void* __rcvr, _As&&... __as) const noexcept { + auto operator()(_Tag, void* __rcvr, _As&&... __as) const noexcept -> _Ret { return __fn_(__rcvr, static_cast<_As&&>(__as)...); } }; @@ -72,7 +72,7 @@ namespace exec { struct __query_vfun<_Tag (*)(_Ret (*)(_As...) noexcept)> { _Ret (*__fn_)(void*, _As...) noexcept; - _Ret operator()(_Tag, void* __rcvr, _As&&... __as) const noexcept { + auto operator()(_Tag, void* __rcvr, _As&&... __as) const noexcept -> _Ret { return __fn_(__rcvr, static_cast<_As&&>(__as)...); } }; @@ -234,8 +234,9 @@ namespace exec { inline constexpr __storage_vtable<_ParentVTable, _StorageCPOs...> __null_storage_vtbl{}; template - constexpr const __storage_vtable<_ParentVTable, _StorageCPOs...>* - __default_storage_vtable(__storage_vtable<_ParentVTable, _StorageCPOs...>*) noexcept { + constexpr auto + __default_storage_vtable(__storage_vtable<_ParentVTable, _StorageCPOs...>*) noexcept + -> const __storage_vtable<_ParentVTable, _StorageCPOs...>* { return &__null_storage_vtbl<_ParentVTable, _StorageCPOs...>; } @@ -271,7 +272,7 @@ namespace exec { sizeof(_Tp) <= __buffer_size && alignof(_Tp) <= __alignment; template - static constexpr const __vtable_t* __get_vtable_of_type() noexcept { + static constexpr auto __get_vtable_of_type() noexcept -> const __vtable_t* { return &__storage_vtbl<__t, __decay_t<_Tp>, _Vtable, __with_delete>; } public: @@ -312,11 +313,13 @@ namespace exec { __vtable_ = __default_storage_vtable(static_cast<__vtable_t*>(nullptr)); } - const _Vtable* __get_vtable() const noexcept { + [[nodiscard]] + auto __get_vtable() const noexcept -> const _Vtable* { return __vtable_; } - void* __get_object_pointer() const noexcept { + [[nodiscard]] + auto __get_object_pointer() const noexcept -> void* { return __object_pointer_; } @@ -396,7 +399,7 @@ namespace exec { __storage_vtable<_Vtable, __with_delete, __with_move>>; template - static constexpr const __vtable_t* __get_vtable_of_type() noexcept { + static constexpr auto __get_vtable_of_type() noexcept -> const __vtable_t* { if constexpr (_Copyable) { return &__storage_vtbl< __t, @@ -444,7 +447,7 @@ namespace exec { (*__other.__vtable_)(__copy_construct, this, __other); } - __t& operator=(const __t& __other) + auto operator=(const __t& __other) -> __t& requires(_Copyable) { __t tmp(__other); @@ -455,7 +458,7 @@ namespace exec { (*__other.__vtable_)(__move_construct, this, static_cast<__t&&>(__other)); } - __t& operator=(__t&& __other) noexcept { + auto operator=(__t&& __other) noexcept -> __t& { __reset(); (*__other.__vtable_)(__move_construct, this, static_cast<__t&&>(__other)); return *this; @@ -471,11 +474,12 @@ namespace exec { __vtable_ = __default_storage_vtable(static_cast<__vtable_t*>(nullptr)); } - const _Vtable* __get_vtable() const noexcept { + auto __get_vtable() const noexcept -> const _Vtable* { return __vtable_; } - void* __get_object_pointer() const noexcept { + [[nodiscard]] + auto __get_object_pointer() const noexcept -> void* { return __object_pointer_; } @@ -563,8 +567,8 @@ namespace exec { struct __empty_vtable { template - friend const __empty_vtable* - tag_invoke(__create_vtable_t, __mtype<__empty_vtable>, __mtype<_Sender>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__empty_vtable>, __mtype<_Sender>) noexcept + -> const __empty_vtable* { static const __empty_vtable __vtable_{}; return &__vtable_; } @@ -580,10 +584,10 @@ namespace exec { using __copyable_storage_t = __t<__storage<_VTable, _Allocator, true>>; template - _Tag __tag_type(_Tag (*)(_As...)); + auto __tag_type(_Tag (*)(_As...)) -> _Tag; template - _Tag __tag_type(_Tag (*)(_As...) noexcept); + auto __tag_type(_Tag (*)(_As...) noexcept) -> _Tag; template concept __is_stop_token_query = requires { @@ -636,7 +640,8 @@ namespace exec { template requires receiver_of<_Rcvr, completion_signatures<_Sigs...>> && (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...) - friend const __t* tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Rcvr>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Rcvr>) noexcept + -> const __t* { static const __t __vtable_{ {__rcvr_vfun_fn<_Rcvr>{}(static_cast<_Sigs*>(nullptr))}..., {__query_vfun_fn<_Rcvr>{}(static_cast<_Queries>(nullptr))}...}; @@ -668,7 +673,8 @@ namespace exec { return (*__self.__vtable_)(_Tag{}, __self.__rcvr_, static_cast<_As&&>(__as)...); } - friend in_place_stop_token tag_invoke(get_stop_token_t, const __env_t& __self) noexcept { + friend auto tag_invoke(get_stop_token_t, const __env_t& __self) noexcept + -> in_place_stop_token { return __self.__token_; } } __env_; @@ -695,18 +701,19 @@ namespace exec { } template Self> - friend const __env_t& tag_invoke(get_env_t, const Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const Self& __self) noexcept -> const __env_t& { return __self.__env_; } }; - __mbool __test_never_stop_token(get_stop_token_t (*)(never_stop_token (*)() noexcept)); + auto __test_never_stop_token(get_stop_token_t (*)(never_stop_token (*)() noexcept)) + -> __mbool; template - __mbool __test_never_stop_token(_Tag (*)(_Ret (*)(_As...) noexcept)); + auto __test_never_stop_token(_Tag (*)(_Ret (*)(_As...) noexcept)) -> __mbool; template - __mbool __test_never_stop_token(_Tag (*)(_Ret (*)(_As...))); + auto __test_never_stop_token(_Tag (*)(_Ret (*)(_As...))) -> __mbool; template using __is_never_stop_token_query = @@ -757,7 +764,7 @@ namespace exec { } template Self> - friend const __env_t& tag_invoke(get_env_t, const Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const Self& __self) noexcept -> const __env_t& { return __self.__env_; } }; @@ -769,8 +776,8 @@ namespace exec { private: template - friend const __operation_vtable* - tag_invoke(__create_vtable_t, __mtype<__operation_vtable>, __mtype<_Op>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__operation_vtable>, __mtype<_Op>) noexcept + -> const __operation_vtable* { static __operation_vtable __vtable{[](void* __object_pointer) noexcept -> void { STDEXEC_ASSERT(__object_pointer); _Op& __op = *static_cast<_Op*>(__object_pointer); @@ -845,7 +852,8 @@ namespace exec { } template _GetEnv, same_as<__t> _Self> - friend __env_t> tag_invoke(_GetEnv, const _Self& __self) noexcept { + friend auto tag_invoke(_GetEnv, const _Self& __self) noexcept + -> __env_t> { return __env::__join( __env::__with(__self.__op_->__stop_source_.get_token(), get_stop_token), get_env(__self.__op_->__rcvr_)); @@ -921,8 +929,9 @@ namespace exec { private: template requires(__callable<__query_vfun_fn<_EnvProvider>, _Queries> && ...) - friend const __query_vtable* - tag_invoke(__create_vtable_t, __mtype<__query_vtable>, __mtype<_EnvProvider>) noexcept { + friend auto + tag_invoke(__create_vtable_t, __mtype<__query_vtable>, __mtype<_EnvProvider>) noexcept + -> const __query_vtable* { static const __query_vtable __vtable{ {__query_vfun_fn<_EnvProvider>{}(static_cast<_Queries>(nullptr))}...}; return &__vtable; @@ -939,15 +948,15 @@ namespace exec { public: using __id = __vtable; - const __query_vtable<_SenderQueries>& __queries() const noexcept { + auto __queries() const noexcept -> const __query_vtable<_SenderQueries>& { return *this; } __immovable_operation_storage (*__connect_)(void*, __receiver_ref_t); private: template _Sender> - friend const __vtable* - tag_invoke(__create_vtable_t, __mtype<__vtable>, __mtype<_Sender>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__vtable>, __mtype<_Sender>) noexcept + -> const __vtable* { static const __vtable __vtable_{ {*__create_vtable(__mtype<__query_vtable<_SenderQueries>>{}, __mtype<_Sender>{})}, [](void* __object_pointer, __receiver_ref_t __receiver) @@ -991,10 +1000,10 @@ namespace exec { using sender_concept = stdexec::sender_t; __t(const __t&) = delete; - __t& operator=(const __t&) = delete; + auto operator=(const __t&) -> __t& = delete; __t(__t&&) = default; - __t& operator=(__t&&) = default; + auto operator=(__t&&) -> __t& = default; template <__not_decays_to<__t> _Sender> requires sender_to<_Sender, __receiver_ref<_Sigs, _ReceiverQueries>> @@ -1002,7 +1011,7 @@ namespace exec { : __storage_{static_cast<_Sender&&>(__sndr)} { } - __immovable_operation_storage __connect(__receiver_ref_t __receiver) { + auto __connect(__receiver_ref_t __receiver) -> __immovable_operation_storage { return __storage_.__get_vtable()->__connect_( __storage_.__get_object_pointer(), static_cast<__receiver_ref_t&&>(__receiver)); } @@ -1015,12 +1024,12 @@ namespace exec { __unique_storage_t<__vtable> __storage_; template _Rcvr> - friend stdexec::__t<__operation>, __with_in_place_stop_token>> - tag_invoke(connect_t, __t&& __self, _Rcvr&& __rcvr) { + friend auto tag_invoke(connect_t, __t&& __self, _Rcvr&& __rcvr) + -> stdexec::__t<__operation>, __with_in_place_stop_token>> { return {static_cast<__t&&>(__self), static_cast<_Rcvr&&>(__rcvr)}; } - friend __env_t tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> __env_t { return {__self.__storage_.__get_vtable(), __self.__storage_.__get_object_pointer()}; } }; @@ -1042,13 +1051,13 @@ namespace exec { __sender_t (*__schedule_)(void*) noexcept; bool (*__equal_to_)(const void*, const void* other) noexcept; - const __query_vtable<_SchedulerQueries>& __queries() const noexcept { + auto __queries() const noexcept -> const __query_vtable<_SchedulerQueries>& { return *this; } private: template - friend const __vtable* - tag_invoke(__create_vtable_t, __mtype<__vtable>, __mtype<_Scheduler>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__vtable>, __mtype<_Scheduler>) noexcept + -> const __vtable* { static const __vtable __vtable_{ {*__create_vtable(__mtype<__query_vtable<_SchedulerQueries>>{}, __mtype<_Scheduler>{})}, [](void* __object_pointer) noexcept -> __sender_t { @@ -1068,7 +1077,7 @@ namespace exec { }; template _Self> - friend __sender_t tag_invoke(schedule_t, const _Self& __self) noexcept { + friend auto tag_invoke(schedule_t, const _Self& __self) noexcept -> __sender_t { STDEXEC_ASSERT(__self.__storage_.__get_vtable()->__schedule_); return __self.__storage_.__get_vtable()->__schedule_( __self.__storage_.__get_object_pointer()); @@ -1083,7 +1092,8 @@ namespace exec { _Tag{}, __self.__storage_.__get_object_pointer(), static_cast<_As&&>(__as)...); } - friend bool operator==(const __scheduler& __self, const __scheduler& __other) noexcept { + friend auto operator==(const __scheduler& __self, const __scheduler& __other) noexcept + -> bool { if (__self.__storage_.__get_vtable() != __other.__storage_.__get_vtable()) { return false; } @@ -1095,7 +1105,8 @@ namespace exec { || (!__p && !__o); } - friend bool operator!=(const __scheduler& __self, const __scheduler& __other) noexcept { + friend auto operator!=(const __scheduler& __self, const __scheduler& __other) noexcept + -> bool { return !(__self == __other); } @@ -1165,7 +1176,7 @@ namespace exec { using __schedule_receiver = any_receiver_ref<__schedule_completions, _ReceiverQueries...>; template - static _Tag __ret_fn(_Tag (*const)(_Sig)); + static auto __ret_fn(_Tag (*const)(_Sig)) -> _Tag; template struct __ret_equals_to { @@ -1222,8 +1233,8 @@ namespace exec { _Tag{}, static_cast(__self).__scheduler_, static_cast<_As&&>(__as)...); } - friend bool - operator==(const any_scheduler& __self, const any_scheduler& __other) noexcept = default; + friend auto operator==(const any_scheduler& __self, const any_scheduler& __other) noexcept + -> bool = default; }; }; }; diff --git a/include/exec/async_scope.hpp b/include/exec/async_scope.hpp index 5c84908a2..2652f0d83 100644 --- a/include/exec/async_scope.hpp +++ b/include/exec/async_scope.hpp @@ -110,8 +110,8 @@ namespace exec { template <__decays_to<__t> _Self, receiver _Receiver> requires sender_to<__copy_cvref_t<_Self, _Constrained>, _Receiver> [[nodiscard]] - friend __when_empty_op_t<_Self, _Receiver> - tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) + -> __when_empty_op_t<_Self, _Receiver> { return __when_empty_op_t<_Self, _Receiver>{ __self.__scope_, static_cast<_Self&&>(__self).__c_, static_cast<_Receiver&&>(__rcvr)}; } @@ -122,7 +122,7 @@ namespace exec { return {}; } - friend empty_env tag_invoke(get_env_t, const __t&) noexcept { + friend auto tag_invoke(get_env_t, const __t&) noexcept -> empty_env { return {}; } @@ -180,7 +180,8 @@ namespace exec { __complete(__scope); } - friend __env_t> tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept + -> __env_t> { return make_env( get_env(__self.__op_->__rcvr_), with(get_stop_token, __self.__op_->__scope_->__stop_source_.get_token())); @@ -240,8 +241,8 @@ namespace exec { template <__decays_to<__t> _Self, receiver _Receiver> requires sender_to<__copy_cvref_t<_Self, _Constrained>, __nest_receiver_t<_Receiver>> [[nodiscard]] - friend __nest_operation_t<_Receiver> - tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) + -> __nest_operation_t<_Receiver> { return __nest_operation_t<_Receiver>{ __self.__scope_, static_cast<_Self&&>(__self).__c_, static_cast<_Receiver&&>(__rcvr)}; } @@ -252,7 +253,7 @@ namespace exec { return {}; } - friend empty_env tag_invoke(get_env_t, const __t&) noexcept { + friend auto tag_invoke(get_env_t, const __t&) noexcept -> empty_env { return {}; } }; @@ -412,7 +413,7 @@ namespace exec { #else template - std::tuple<_Tag, _Ts...> __completion_as_tuple_(_Tag (*)(_Ts&&...)); + auto __completion_as_tuple_(_Tag (*)(_Ts&&...)) -> std::tuple<_Tag, _Ts...>; template using __completion_as_tuple_t = decltype(__scope::__completion_as_tuple_(static_cast<_Fn*>(nullptr))); @@ -453,7 +454,7 @@ namespace exec { template requires convertible_to<_Uy*, _Ty*> - __dynamic_delete& operator=(std::default_delete<_Uy> __d) { + auto operator=(std::default_delete<_Uy> __d) -> __dynamic_delete& { __delete_ = __dynamic_delete{__d}.__delete_; return *this; } @@ -549,7 +550,7 @@ namespace exec { } } - friend const __env_t<_Env>& tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> const __env_t<_Env>& { return __self.__state_->__env_; } }; @@ -583,7 +584,7 @@ namespace exec { using sender_concept = stdexec::sender_t; __t(__t&&) = default; - __t& operator=(__t&&) = default; + auto operator=(__t&&) -> __t& = default; ~__t() noexcept { if (__state_ != nullptr) { @@ -616,7 +617,8 @@ namespace exec { template <__decays_to<__t> _Self, receiver _Receiver> requires receiver_of<_Receiver, __completions_t<_Self>> - friend __future_op_t<_Receiver> tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr) + -> __future_op_t<_Receiver> { return __future_op_t<_Receiver>{ static_cast<_Receiver&&>(__rcvr), std::move(__self.__state_)}; } @@ -626,8 +628,8 @@ namespace exec { -> __completions_t<_Self> { return {}; } - - friend empty_env tag_invoke(get_env_t, const __t&) noexcept { + + friend auto tag_invoke(get_env_t, const __t&) noexcept -> empty_env { return {}; } @@ -675,7 +677,8 @@ namespace exec { std::rethrow_exception(std::move(__eptr)); } - friend const __spawn_env_t<_Env>& tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept + -> const __spawn_env_t<_Env>& { return __self.__op_->__env_; } }; @@ -723,7 +726,7 @@ namespace exec { template [[nodiscard]] - __when_empty_sender_t<_Constrained> when_empty(_Constrained&& __c) const { + auto when_empty(_Constrained&& __c) const -> __when_empty_sender_t<_Constrained> { return __when_empty_sender_t<_Constrained>{&__impl_, static_cast<_Constrained&&>(__c)}; } @@ -737,7 +740,7 @@ namespace exec { template [[nodiscard]] - nest_result_t<_Constrained> nest(_Constrained&& __c) { + auto nest(_Constrained&& __c) -> nest_result_t<_Constrained> { return nest_result_t<_Constrained>{&__impl_, static_cast<_Constrained&&>(__c)}; } @@ -753,7 +756,7 @@ namespace exec { } template <__movable_value _Env = empty_env, sender_in<__env_t<_Env>> _Sender> - __future_t<_Sender, _Env> spawn_future(_Sender&& __sndr, _Env __env = {}) { + auto spawn_future(_Sender&& __sndr, _Env __env = {}) -> __future_t<_Sender, _Env> { using __state_t = __future_state, _Env>; auto __state = std::make_unique<__state_t>( nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_); @@ -761,15 +764,15 @@ namespace exec { return __future_t<_Sender, _Env>{std::move(__state)}; } - in_place_stop_source& get_stop_source() noexcept { + auto get_stop_source() noexcept -> in_place_stop_source& { return __impl_.__stop_source_; } - in_place_stop_token get_stop_token() const noexcept { + auto get_stop_token() const noexcept -> in_place_stop_token { return __impl_.__stop_source_.get_token(); } - bool request_stop() noexcept { + auto request_stop() noexcept -> bool { return __impl_.__stop_source_.request_stop(); } diff --git a/include/exec/at_coroutine_exit.hpp b/include/exec/at_coroutine_exit.hpp index ac0151db0..ceed7dc45 100644 --- a/include/exec/at_coroutine_exit.hpp +++ b/include/exec/at_coroutine_exit.hpp @@ -54,7 +54,7 @@ namespace exec { std::terminate(); } - friend env_of_t<_Receiver> tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__receiver_); } }; @@ -78,8 +78,8 @@ namespace exec { template requires sender_to<_Sender, __receiver<_Receiver>> - friend connect_result_t<_Sender, __receiver<_Receiver>> - tag_invoke(connect_t, __t&& __self, _Receiver&& __rcvr) noexcept { + friend auto tag_invoke(connect_t, __t&& __self, _Receiver&& __rcvr) noexcept + -> connect_result_t<_Sender, __receiver<_Receiver>> { return stdexec::connect( static_cast<_Sender&&>(__self.__sender_), __receiver<_Receiver>{static_cast<_Receiver&&>(__rcvr)}); @@ -91,7 +91,7 @@ namespace exec { return {}; } - friend env_of_t<_Sender> tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> env_of_t<_Sender> { return get_env(__self.__sender_); } }; @@ -100,13 +100,13 @@ namespace exec { using __sender = __t<__sender_id<__decay_t<_Sender>>>; template - __sender<_Sender> operator()(_Sender&& __sndr) const - noexcept(__nothrow_decay_copyable<_Sender>) { + auto operator()(_Sender&& __sndr) const noexcept(__nothrow_decay_copyable<_Sender>) + -> __sender<_Sender> { return __sender<_Sender>{static_cast<_Sender&&>(__sndr)}; } template - _Value&& operator()(_Value&& __value) const noexcept { + auto operator()(_Value&& __value) const noexcept -> _Value&& { return static_cast<_Value&&>(__value); } }; @@ -134,30 +134,31 @@ namespace exec { : __coro_(std::exchange(__that.__coro_, {})) { } - bool await_ready() const noexcept { + [[nodiscard]] + auto await_ready() const noexcept -> bool { return false; } template <__has_continuation _Promise> - bool await_suspend(__coro::coroutine_handle<_Promise> __parent) noexcept { + auto await_suspend(__coro::coroutine_handle<_Promise> __parent) noexcept -> bool { __coro_.promise().__scheduler_ = get_scheduler(get_env(__parent.promise())); __coro_.promise().set_continuation(__parent.promise().continuation()); __parent.promise().set_continuation(__coro_); return false; } - std::tuple<_Ts&...> await_resume() noexcept { + auto await_resume() noexcept -> std::tuple<_Ts&...> { return std::exchange(__coro_, {}).promise().__args_; } private: struct __final_awaitable { - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } - static __coro::coroutine_handle<> await_suspend( - __coro::coroutine_handle<__promise> __h) noexcept { + static auto await_suspend(__coro::coroutine_handle<__promise> __h) noexcept + -> __coro::coroutine_handle<> { __promise& __p = __h.promise(); auto __coro = __p.__is_unhandled_stopped_ ? __p.continuation().unhandled_stopped() @@ -172,7 +173,7 @@ namespace exec { struct __env { const __promise& __promise_; - friend __any_scheduler tag_invoke(get_scheduler_t, __env __self) noexcept { + friend auto tag_invoke(get_scheduler_t, __env __self) noexcept -> __any_scheduler { return __self.__promise_.__scheduler_; } }; @@ -183,11 +184,11 @@ namespace exec { : __args_{__ts...} { } - __coro::suspend_always initial_suspend() noexcept { + auto initial_suspend() noexcept -> __coro::suspend_always { return {}; } - __final_awaitable final_suspend() noexcept { + auto final_suspend() noexcept -> __final_awaitable { return {}; } @@ -199,21 +200,21 @@ namespace exec { std::terminate(); } - __coro::coroutine_handle<__promise> unhandled_stopped() noexcept { + auto unhandled_stopped() noexcept -> __coro::coroutine_handle<__promise> { __is_unhandled_stopped_ = true; return __coro::coroutine_handle<__promise>::from_promise(*this); } - __task get_return_object() noexcept { + auto get_return_object() noexcept -> __task { return __task(__coro::coroutine_handle<__promise>::from_promise(*this)); } template - decltype(auto) await_transform(_Awaitable&& __awaitable) noexcept { + auto await_transform(_Awaitable&& __awaitable) noexcept -> decltype(auto) { return as_awaitable(__die_on_stop(static_cast<_Awaitable&&>(__awaitable)), *this); } - friend __env tag_invoke(get_env_t, const __promise& __self) noexcept { + friend auto tag_invoke(get_env_t, const __promise& __self) noexcept -> __env { return {__self}; } @@ -228,14 +229,14 @@ namespace exec { struct __at_coro_exit_t { private: template - static __task<_Ts...> __impl(_Action __action, _Ts... __ts) { + static auto __impl(_Action __action, _Ts... __ts) -> __task<_Ts...> { co_await static_cast<_Action&&>(__action)(static_cast<_Ts&&>(__ts)...); } public: template requires __callable<__decay_t<_Action>, __decay_t<_Ts>...> - __task<_Ts...> operator()(_Action&& __action, _Ts&&... __ts) const { + auto operator()(_Action&& __action, _Ts&&... __ts) const -> __task<_Ts...> { return __impl(static_cast<_Action&&>(__action), static_cast<_Ts&&>(__ts)...); } }; diff --git a/include/exec/create.hpp b/include/exec/create.hpp index 1f4f2844f..38949f648 100644 --- a/include/exec/create.hpp +++ b/include/exec/create.hpp @@ -88,7 +88,7 @@ namespace exec { }; } - friend empty_env tag_invoke(get_env_t, const __t&) noexcept { + friend auto tag_invoke(get_env_t, const __t&) noexcept -> empty_env { return {}; } }; diff --git a/include/exec/env.hpp b/include/exec/env.hpp index c312cd2f0..374a0af7a 100644 --- a/include/exec/env.hpp +++ b/include/exec/env.hpp @@ -34,7 +34,7 @@ namespace exec { struct __without_t { template - decltype(auto) operator()(_Env&& __env, _Tag) const { + auto operator()(_Env&& __env, _Tag) const -> decltype(auto) { return stdexec::__env::__without(static_cast<_Env&&>(__env), _Tag()); } }; @@ -51,7 +51,7 @@ namespace exec { } template - _Env operator()(_Env&& __env) const noexcept { + auto operator()(_Env&& __env) const noexcept -> _Env { return static_cast<_Env&&>(__env); } }; diff --git a/include/exec/finally.hpp b/include/exec/finally.hpp index 079156375..d32b08d7d 100644 --- a/include/exec/finally.hpp +++ b/include/exec/finally.hpp @@ -143,7 +143,7 @@ namespace exec { } template _Self> - friend env_of_t<_Receiver> tag_invoke(get_env_t, const _Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const _Self& __self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__op_->__receiver_); } }; @@ -194,7 +194,7 @@ namespace exec { } template _Self> - friend env_of_t<_Receiver> tag_invoke(get_env_t, const _Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const _Self& __self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__op_->__receiver_); } }; @@ -261,8 +261,8 @@ namespace exec { _FinalSender __final_sndr_; template <__decays_to<__t> _Self, class _Rec> - friend __op_t<_Self, _Rec> - tag_invoke(connect_t, _Self&& __self, _Rec&& __receiver) noexcept { + friend auto tag_invoke(connect_t, _Self&& __self, _Rec&& __receiver) noexcept + -> __op_t<_Self, _Rec> { return { static_cast<_Self&&>(__self).__initial_sndr_, static_cast<_Self&&>(__self).__final_sndr_, diff --git a/include/exec/linux/__detail/memory_mapped_region.hpp b/include/exec/linux/__detail/memory_mapped_region.hpp index a63b94184..12f536f75 100644 --- a/include/exec/linux/__detail/memory_mapped_region.hpp +++ b/include/exec/linux/__detail/memory_mapped_region.hpp @@ -42,8 +42,8 @@ namespace exec { , __size_(std::exchange(__other.__size_, 0)) { } - inline memory_mapped_region& memory_mapped_region::operator=( - memory_mapped_region&& __other) noexcept { + inline auto memory_mapped_region::operator=(memory_mapped_region&& __other) noexcept + -> memory_mapped_region& { if (this != &__other) { if (__ptr_) { ::munmap(__ptr_, __size_); @@ -58,11 +58,11 @@ namespace exec { return __ptr_ != nullptr; } - inline void* memory_mapped_region::data() const noexcept { + inline auto memory_mapped_region::data() const noexcept -> void* { return __ptr_; } - inline std::size_t memory_mapped_region::size() const noexcept { + inline auto memory_mapped_region::size() const noexcept -> std::size_t { return __size_; } } // namespace exec \ No newline at end of file diff --git a/include/exec/linux/__detail/safe_file_descriptor.hpp b/include/exec/linux/__detail/safe_file_descriptor.hpp index add558df0..c5c63af6a 100644 --- a/include/exec/linux/__detail/safe_file_descriptor.hpp +++ b/include/exec/linux/__detail/safe_file_descriptor.hpp @@ -30,8 +30,8 @@ namespace exec { : __fd_(std::exchange(__other.__fd_, -1)) { } - inline safe_file_descriptor& safe_file_descriptor::operator=( - safe_file_descriptor&& __other) noexcept { + inline auto safe_file_descriptor::operator=(safe_file_descriptor&& __other) noexcept + -> safe_file_descriptor& { if (this != &__other) { if (__fd_ != -1) { ::close(__fd_); @@ -60,7 +60,7 @@ namespace exec { return __fd_; } - inline int safe_file_descriptor::native_handle() const noexcept { + inline auto safe_file_descriptor::native_handle() const noexcept -> int { return __fd_; } } // namespace exec \ No newline at end of file diff --git a/include/exec/linux/io_uring_context.hpp b/include/exec/linux/io_uring_context.hpp index b6b150a6d..4e5d4026e 100644 --- a/include/exec/linux/io_uring_context.hpp +++ b/include/exec/linux/io_uring_context.hpp @@ -63,17 +63,18 @@ namespace exec { } } - inline safe_file_descriptor __io_uring_setup(unsigned __entries, ::io_uring_params& __params) { + inline auto __io_uring_setup(unsigned __entries, ::io_uring_params& __params) + -> safe_file_descriptor { int rc = static_cast(::syscall(__NR_io_uring_setup, __entries, &__params)); __throw_error_code_if(rc < 0, -rc); return safe_file_descriptor{rc}; } - inline int __io_uring_enter( + inline auto __io_uring_enter( int __ring_fd, unsigned int __to_submit, unsigned int __min_complete, - unsigned int __flags) { + unsigned int __flags) -> int { int rc = static_cast(::syscall( __NR_io_uring_enter, __ring_fd, __to_submit, __min_complete, __flags, nullptr, 0)); if (rc == -1) { @@ -83,7 +84,8 @@ namespace exec { } } - inline memory_mapped_region __map_region(int __fd, ::off_t __offset, std::size_t __size) { + inline auto __map_region(int __fd, ::off_t __offset, std::size_t __size) + -> memory_mapped_region { void* __ptr = ::mmap( nullptr, __size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, __fd, __offset); __throw_error_code_if(__ptr == MAP_FAILED, errno); @@ -155,7 +157,7 @@ namespace exec { using __atomic_task_queue = __atomic_intrusive_queue<&__task::__next_>; template - inline _Ty __at_offset_as(void* __pointer, __u32 __offset) { + inline auto __at_offset_as(void* __pointer, __u32 __offset) -> _Ty { return reinterpret_cast<_Ty>(static_cast(__pointer) + __offset); } @@ -201,8 +203,8 @@ namespace exec { // If is_stopped is true, no new tasks are submitted to the io_uring unless it is a cancellation. // If is_stopped is true and a task is not ready to be completed, the task is completed with // an io_uring_cqe object with the result field set to -ECANCELED. - __submission_result - submit(__task_queue __tasks, __u32 __max_submissions, bool __is_stopped) noexcept { + auto submit(__task_queue __tasks, __u32 __max_submissions, bool __is_stopped) noexcept + -> __submission_result { __u32 __tail = __tail_.load(std::memory_order_relaxed); __u32 __head = __head_.load(std::memory_order_acquire); __u32 __current_count = __tail - __head; @@ -264,14 +266,15 @@ namespace exec { // This function first completes all tasks that are ready in the completion queue of the io_uring. // Then it completes all tasks that are ready in the given queue of ready tasks. // The function returns the number of previously submitted completed tasks. - int complete(stdexec::__intrusive_queue<&__task::__next_> __ready = __task_queue{}) noexcept { + auto complete(stdexec::__intrusive_queue<&__task::__next_> __ready = __task_queue{}) noexcept + -> int { __u32 __head = __head_.load(std::memory_order_relaxed); __u32 __tail = __tail_.load(std::memory_order_acquire); int __count = 0; while (__head != __tail) { const __u32 __index = __head & __mask_; const ::io_uring_cqe& __cqe = __entries_[__index]; - __task* __op = bit_cast<__task*>(__cqe.user_data); + auto* __op = bit_cast<__task*>(__cqe.user_data); __op->__vtable_->__complete_(__op, __cqe); ++__head; ++__count; @@ -299,7 +302,7 @@ namespace exec { ::iovec __buffer_ = {.iov_base = &__value_, .iov_len = sizeof(__value_)}; # endif - static bool __ready_(__task*) noexcept { + static auto __ready_(__task*) noexcept -> bool { return false; } @@ -369,15 +372,15 @@ namespace exec { wakeup(); } - bool stop_requested() const noexcept { + auto stop_requested() const noexcept -> bool { return __stop_source_->stop_requested(); } - stdexec::in_place_stop_token get_stop_token() const noexcept { + auto get_stop_token() const noexcept -> stdexec::in_place_stop_token { return __stop_source_->get_token(); } - bool is_running() const noexcept { + auto is_running() const noexcept -> bool { return __is_running_.load(std::memory_order_relaxed); } @@ -389,7 +392,7 @@ namespace exec { /// \brief Submits the given task to the io_uring. /// \returns true if the task was submitted, false if this io context and this task is have been stopped. - bool submit(__task* __op) noexcept { + auto submit(__task* __op) noexcept -> bool { // As long as the number of in-flight submissions is not __no_new_submissions, we can // increment the counter and push the operation onto the queue. // If the number of in-flight submissions is __no_new_submissions, we have already @@ -589,7 +592,7 @@ namespace exec { } }; - __run_sender run(until __mode = until::stopped) { + auto run(until __mode = until::stopped) -> __run_sender { return __run_sender{this, __mode}; } @@ -598,7 +601,7 @@ namespace exec { run_until_stopped(); } - __scheduler get_scheduler() noexcept; + auto get_scheduler() noexcept -> __scheduler; private: friend struct __wakeup_operation; @@ -650,18 +653,18 @@ namespace exec { template <__io_task _Base> struct __io_task_facade : __task { - static bool __ready_(__task* __pointer) noexcept { - __io_task_facade* __self = static_cast<__io_task_facade*>(__pointer); + static auto __ready_(__task* __pointer) noexcept -> bool { + auto* __self = static_cast<__io_task_facade*>(__pointer); return __self->__base_.ready(); } static void __submit_(__task* __pointer, ::io_uring_sqe& __sqe) noexcept { - __io_task_facade* __self = static_cast<__io_task_facade*>(__pointer); + auto* __self = static_cast<__io_task_facade*>(__pointer); __self->__base_.submit(__sqe); } static void __complete_(__task* __pointer, const ::io_uring_cqe& __cqe) noexcept { - __io_task_facade* __self = static_cast<__io_task_facade*>(__pointer); + auto* __self = static_cast<__io_task_facade*>(__pointer); __self->__base_.complete(__cqe); } @@ -683,7 +686,7 @@ namespace exec { , __base_(static_cast<_Args&&>(__args)...) { } - _Base& base() noexcept { + auto base() noexcept -> _Base& { return __base_; } @@ -712,11 +715,12 @@ namespace exec { , __receiver_{static_cast<_Receiver&&>(__receiver)} { } - __context& context() const noexcept { + [[nodiscard]] + auto context() const noexcept -> __context& { return __context_; } - static constexpr std::true_type ready() noexcept { + static constexpr auto ready() noexcept -> std::true_type { return {}; } @@ -741,7 +745,7 @@ namespace exec { class __t : public __task { _Base* __op_; public: - static bool __ready_(__task*) noexcept { + static auto __ready_(__task*) noexcept -> bool { return false; } @@ -864,19 +868,20 @@ namespace exec { , __stop_operation_{this} { } - __context& context() noexcept { + auto context() noexcept -> __context& { return this->__base_.context(); } - _Receiver& receiver() & noexcept { + auto receiver() & noexcept -> _Receiver& { return this->__base_.receiver(); } - _Receiver&& receiver() && noexcept { + auto receiver() && noexcept -> _Receiver&& { return static_cast<_Receiver&&>(this->__base_.receiver()); } - bool ready() const noexcept { + [[nodiscard]] + auto ready() const noexcept -> bool { return this->__base_.ready(); } @@ -918,15 +923,15 @@ namespace exec { __context& __context_; _Receiver __receiver_; - _Receiver& receiver() & noexcept { + auto receiver() & noexcept -> _Receiver& { return __receiver_; } - _Receiver&& receiver() && noexcept { + auto receiver() && noexcept -> _Receiver&& { return static_cast<_Receiver&&>(__receiver_); } - __context& context() noexcept { + auto context() noexcept -> __context& { return __context_; } }; @@ -944,8 +949,8 @@ namespace exec { __kernel_timespec __duration_; - static constexpr __kernel_timespec __duration_to_timespec( - std::chrono::nanoseconds dur) noexcept { + static constexpr auto __duration_to_timespec(std::chrono::nanoseconds dur) noexcept + -> __kernel_timespec { auto secs = std::chrono::duration_cast(dur); dur -= secs; secs = std::max(secs, std::chrono::seconds{0}); @@ -976,7 +981,7 @@ namespace exec { # endif public: - static constexpr std::false_type ready() noexcept { + static constexpr auto ready() noexcept -> std::false_type { return {}; } @@ -1046,15 +1051,15 @@ namespace exec { public: __context* __context_; - friend bool operator==(const __scheduler& __lhs, const __scheduler& __rhs) = default; + friend auto operator==(const __scheduler& __lhs, const __scheduler& __rhs) -> bool = default; class __schedule_env { public: __context* __context_; private: - friend __scheduler tag_invoke( + friend auto tag_invoke( stdexec::get_completion_scheduler_t, - const __schedule_env& __env) noexcept { + const __schedule_env& __env) noexcept -> __scheduler { return __scheduler{__env.__context_}; } }; @@ -1071,8 +1076,8 @@ namespace exec { } private: - friend __schedule_env - tag_invoke(stdexec::get_env_t, const __schedule_sender& __sender) noexcept { + friend auto tag_invoke(stdexec::get_env_t, const __schedule_sender& __sender) noexcept + -> __schedule_env { return __sender.__env_; } @@ -1080,18 +1085,16 @@ namespace exec { stdexec::completion_signatures; template - friend __completion_sigs tag_invoke( - stdexec::get_completion_signatures_t, - const __schedule_sender&, - _Env) noexcept { + friend auto + tag_invoke(stdexec::get_completion_signatures_t, const __schedule_sender&, _Env) noexcept + -> __completion_sigs { return {}; } template _Receiver> - friend stdexec::__t<__schedule_operation>> tag_invoke( - stdexec::connect_t, - const __schedule_sender& __sender, - _Receiver&& __receiver) { + friend auto + tag_invoke(stdexec::connect_t, const __schedule_sender& __sender, _Receiver&& __receiver) + -> stdexec::__t<__schedule_operation>> { return stdexec::__t<__schedule_operation>>( std::in_place, *__sender.__env_.__context_, static_cast<_Receiver&&>(__receiver)); } @@ -1107,8 +1110,8 @@ namespace exec { std::chrono::nanoseconds __duration_; private: - friend __schedule_env - tag_invoke(stdexec::get_env_t, const __schedule_after_sender& __sender) noexcept { + friend auto tag_invoke(stdexec::get_env_t, const __schedule_after_sender& __sender) noexcept + -> __schedule_env { return __sender.__env_; } @@ -1118,18 +1121,19 @@ namespace exec { stdexec::set_stopped_t()>; template - friend __completion_sigs tag_invoke( + friend auto tag_invoke( stdexec::get_completion_signatures_t, const __schedule_after_sender&, - _Env) noexcept { + _Env) noexcept -> __completion_sigs { return {}; } template _Receiver> - friend stdexec::__t<__schedule_after_operation>> tag_invoke( + friend auto tag_invoke( stdexec::connect_t, const __schedule_after_sender& __sender, - _Receiver&& __receiver) { + _Receiver&& __receiver) + -> stdexec::__t<__schedule_after_operation>> { return stdexec::__t<__schedule_after_operation>>( std::in_place, *__sender.__env_.__context_, @@ -1139,33 +1143,33 @@ namespace exec { }; private: - friend __schedule_sender tag_invoke(stdexec::schedule_t, const __scheduler& __sched) { + friend auto tag_invoke(stdexec::schedule_t, const __scheduler& __sched) -> __schedule_sender { return __schedule_sender{__schedule_env{__sched.__context_}}; } - friend std::chrono::time_point - tag_invoke(exec::now_t, const __scheduler& __sched) noexcept { + friend auto tag_invoke(exec::now_t, const __scheduler& __sched) noexcept + -> std::chrono::time_point { return std::chrono::steady_clock::now(); } - friend __schedule_after_sender tag_invoke( + friend auto tag_invoke( exec::schedule_after_t, const __scheduler& __sched, - std::chrono::nanoseconds __duration) { + std::chrono::nanoseconds __duration) -> __schedule_after_sender { return __schedule_after_sender{.__env_ = {__sched.__context_}, .__duration_ = __duration}; } template - friend __schedule_after_sender tag_invoke( + friend auto tag_invoke( exec::schedule_at_t, const __scheduler& __sched, - const std::chrono::time_point<_Clock, _Duration>& __time_point) { + const std::chrono::time_point<_Clock, _Duration>& __time_point) -> __schedule_after_sender { auto __duration = __time_point - _Clock::now(); return __schedule_after_sender{.__env_ = {__sched.__context_}, .__duration_ = __duration}; } }; - inline __scheduler __context::get_scheduler() noexcept { + inline auto __context::get_scheduler() noexcept -> __scheduler { return __scheduler{this}; } } // namespace __io_uring diff --git a/include/exec/linux/memory_mapped_region.hpp b/include/exec/linux/memory_mapped_region.hpp index d8e42a82b..5f060293d 100644 --- a/include/exec/linux/memory_mapped_region.hpp +++ b/include/exec/linux/memory_mapped_region.hpp @@ -31,17 +31,19 @@ namespace exec { ~memory_mapped_region(); memory_mapped_region(const memory_mapped_region&) = delete; - memory_mapped_region& operator=(const memory_mapped_region&) = delete; + auto operator=(const memory_mapped_region&) -> memory_mapped_region& = delete; memory_mapped_region(memory_mapped_region&& __other) noexcept; - memory_mapped_region& operator=(memory_mapped_region&& __other) noexcept; + auto operator=(memory_mapped_region&& __other) noexcept -> memory_mapped_region&; explicit operator bool() const noexcept; - void* data() const noexcept; + [[nodiscard]] + auto data() const noexcept -> void*; - std::size_t size() const noexcept; + [[nodiscard]] + auto size() const noexcept -> std::size_t; }; } // namespace exec diff --git a/include/exec/linux/safe_file_descriptor.hpp b/include/exec/linux/safe_file_descriptor.hpp index 68ac7f7eb..028de3e9a 100644 --- a/include/exec/linux/safe_file_descriptor.hpp +++ b/include/exec/linux/safe_file_descriptor.hpp @@ -25,11 +25,11 @@ namespace exec { explicit safe_file_descriptor(int __fd) noexcept; safe_file_descriptor(const safe_file_descriptor&) = delete; - safe_file_descriptor& operator=(const safe_file_descriptor&) = delete; + auto operator=(const safe_file_descriptor&) -> safe_file_descriptor& = delete; safe_file_descriptor(safe_file_descriptor&& __other) noexcept; - safe_file_descriptor& operator=(safe_file_descriptor&& __other) noexcept; + auto operator=(safe_file_descriptor&& __other) noexcept -> safe_file_descriptor&; ~safe_file_descriptor(); @@ -39,7 +39,8 @@ namespace exec { operator int() const noexcept; - int native_handle() const noexcept; + [[nodiscard]] + auto native_handle() const noexcept -> int; }; } // namespace exec diff --git a/include/exec/materialize.hpp b/include/exec/materialize.hpp index 804c9af9c..24ce160bd 100644 --- a/include/exec/materialize.hpp +++ b/include/exec/materialize.hpp @@ -46,7 +46,7 @@ namespace exec { } template _Self> - friend env_of_t<_Receiver> tag_invoke(get_env_t, const _Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const _Self& __self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__upstream_); } }; @@ -73,9 +73,9 @@ namespace exec { template <__decays_to<__t> _Self, class _Receiver> requires sender_to<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> - friend connect_result_t<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> - tag_invoke(connect_t, _Self&& __self, _Receiver&& __receiver) noexcept( - __nothrow_connectable<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>>) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver&& __receiver) noexcept( + __nothrow_connectable<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>>) + -> connect_result_t<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> { return stdexec::connect( static_cast<_Self&&>(__self).__sender_, __receiver_t<_Receiver>{static_cast<_Receiver&&>(__receiver)}); @@ -111,7 +111,7 @@ namespace exec { return {static_cast<_Sender&&>(__sender)}; } - __binder_back<__materialize_t> operator()() const noexcept { + auto operator()() const noexcept -> __binder_back<__materialize_t> { return {{}, {}, {}}; } }; @@ -154,7 +154,7 @@ namespace exec { } template _Self> - friend env_of_t<_Receiver> tag_invoke(get_env_t, const _Self& __self) noexcept { + friend auto tag_invoke(get_env_t, const _Self& __self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__upstream_); } }; @@ -181,9 +181,9 @@ namespace exec { template <__decays_to<__t> _Self, class _Receiver> requires sender_to<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> - friend connect_result_t<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> - tag_invoke(connect_t, _Self&& __self, _Receiver&& __receiver) noexcept( - __nothrow_connectable<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>>) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver&& __receiver) noexcept( + __nothrow_connectable<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>>) + -> connect_result_t<__copy_cvref_t<_Self, _Sender>, __receiver_t<_Receiver>> { return stdexec::connect( static_cast<_Self&&>(__self).__sender_, __receiver_t<_Receiver>{static_cast<_Receiver&&>(__receiver)}); @@ -210,12 +210,12 @@ namespace exec { using __sender_t = __t<__sender<__id<_Sender>>>; template - __sender_t<_Sender> operator()(_Sender&& __sndr) const - noexcept(__nothrow_decay_copyable<_Sender>) { + auto operator()(_Sender&& __sndr) const noexcept(__nothrow_decay_copyable<_Sender>) + -> __sender_t<_Sender> { return __sender_t<_Sender>(static_cast<_Sender&&>(__sndr)); } - __binder_back<__dematerialize_t> operator()() const noexcept { + auto operator()() const noexcept -> __binder_back<__dematerialize_t> { return {{}, {}, {}}; } }; diff --git a/include/exec/on_coro_disposition.hpp b/include/exec/on_coro_disposition.hpp index 6c4322129..ce5a62ed3 100644 --- a/include/exec/on_coro_disposition.hpp +++ b/include/exec/on_coro_disposition.hpp @@ -46,19 +46,20 @@ namespace exec { struct __get_disposition { task_disposition __disposition_; - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } template - bool await_suspend(__coro::coroutine_handle<_Promise> __h) noexcept { + auto await_suspend(__coro::coroutine_handle<_Promise> __h) noexcept -> bool { auto& __promise = __h.promise(); __disposition_ = // __promise.__get_disposition_callback_(__promise.__parent_.address()); return false; } - task_disposition await_resume() const noexcept { + [[nodiscard]] + auto await_resume() const noexcept -> task_disposition { return __disposition_; } }; @@ -77,12 +78,13 @@ namespace exec { : __coro_(std::exchange(__that.__coro_, {})) { } - bool await_ready() const noexcept { + [[nodiscard]] + auto await_ready() const noexcept -> bool { return false; } template <__promise_with_disposition _Promise> - bool await_suspend(__coro::coroutine_handle<_Promise> __parent) noexcept { + auto await_suspend(__coro::coroutine_handle<_Promise> __parent) noexcept -> bool { __coro_.promise().__parent_ = __parent; __coro_.promise().__get_disposition_callback_ = // [](void* __parent) noexcept { @@ -96,18 +98,18 @@ namespace exec { return false; } - std::tuple<_Ts&...> await_resume() noexcept { + auto await_resume() noexcept -> std::tuple<_Ts&...> { return std::exchange(__coro_, {}).promise().__args_; } private: struct __final_awaitable { - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } - static __coro::coroutine_handle<> await_suspend( - __coro::coroutine_handle<__promise> __h) noexcept { + static auto await_suspend(__coro::coroutine_handle<__promise> __h) noexcept + -> __coro::coroutine_handle<> { __promise& __p = __h.promise(); auto __coro = __p.__is_unhandled_stopped_ ? __p.continuation().unhandled_stopped() @@ -122,7 +124,7 @@ namespace exec { struct __env { const __promise& __promise_; - friend __any_scheduler tag_invoke(get_scheduler_t, __env __self) noexcept { + friend auto tag_invoke(get_scheduler_t, __env __self) noexcept -> __any_scheduler { return __self.__promise_.__scheduler_; } }; @@ -133,11 +135,11 @@ namespace exec { : __args_{__ts...} { } - __coro::suspend_always initial_suspend() noexcept { + auto initial_suspend() noexcept -> __coro::suspend_always { return {}; } - __final_awaitable final_suspend() noexcept { + auto final_suspend() noexcept -> __final_awaitable { return {}; } @@ -149,26 +151,26 @@ namespace exec { std::terminate(); } - __coro::coroutine_handle<__promise> unhandled_stopped() noexcept { + auto unhandled_stopped() noexcept -> __coro::coroutine_handle<__promise> { __is_unhandled_stopped_ = true; return __coro::coroutine_handle<__promise>::from_promise(*this); } - __task get_return_object() noexcept { + auto get_return_object() noexcept -> __task { return __task(__coro::coroutine_handle<__promise>::from_promise(*this)); } - __get_disposition await_transform(__get_disposition __awaitable) noexcept { + auto await_transform(__get_disposition __awaitable) noexcept -> __get_disposition { return __awaitable; } template - decltype(auto) await_transform(_Awaitable&& __awaitable) noexcept { + auto await_transform(_Awaitable&& __awaitable) noexcept -> decltype(auto) { return as_awaitable( __at_coro_exit::__die_on_stop(static_cast<_Awaitable&&>(__awaitable)), *this); } - friend __env tag_invoke(get_env_t, const __promise& __self) noexcept { + friend auto tag_invoke(get_env_t, const __promise& __self) noexcept -> __env { return {__self}; } @@ -187,7 +189,7 @@ namespace exec { class __on_disp { private: template - static __task<_Ts...> __impl(_Action __action, _Ts... __ts) { + static auto __impl(_Action __action, _Ts... __ts) -> __task<_Ts...> { task_disposition __d = co_await __get_disposition(); if (__d == _OnCompletion) { co_await static_cast<_Action&&>(__action)(static_cast<_Ts&&>(__ts)...); @@ -197,7 +199,7 @@ namespace exec { public: template requires __callable<__decay_t<_Action>, __decay_t<_Ts>...> - __task<_Ts...> operator()(_Action&& __action, _Ts&&... __ts) const { + auto operator()(_Action&& __action, _Ts&&... __ts) const -> __task<_Ts...> { return __impl(static_cast<_Action&&>(__action), static_cast<_Ts&&>(__ts)...); } }; diff --git a/include/exec/repeat_effect_until.hpp b/include/exec/repeat_effect_until.hpp index d0e06eaa7..c11855a67 100644 --- a/include/exec/repeat_effect_until.hpp +++ b/include/exec/repeat_effect_until.hpp @@ -53,7 +53,7 @@ namespace exec { __self.__state_->__complete(_Tag(), static_cast<_Args &&>(__args)...); } - friend env_of_t<_Receiver> tag_invoke(get_env_t, const __t &__self) noexcept { + friend auto tag_invoke(get_env_t, const __t &__self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__state_->__receiver()); } }; diff --git a/include/exec/repeat_n.hpp b/include/exec/repeat_n.hpp index fc72f901d..8400b5066 100644 --- a/include/exec/repeat_n.hpp +++ b/include/exec/repeat_n.hpp @@ -54,7 +54,7 @@ namespace exec { __self.__state_->__complete(_Tag(), static_cast<_Args &&>(__args)...); } - friend env_of_t<_Receiver> tag_invoke(get_env_t, const __t &__self) noexcept { + friend auto tag_invoke(get_env_t, const __t &__self) noexcept -> env_of_t<_Receiver> { return get_env(__self.__state_->__receiver()); } }; diff --git a/include/exec/reschedule.hpp b/include/exec/reschedule.hpp index 755d09169..8d9f85272 100644 --- a/include/exec/reschedule.hpp +++ b/include/exec/reschedule.hpp @@ -66,11 +66,11 @@ namespace exec { } }; - friend __sender tag_invoke(schedule_t, __scheduler) noexcept { + friend auto tag_invoke(schedule_t, __scheduler) noexcept -> __sender { return {}; } - bool operator==(const __scheduler&) const noexcept = default; + auto operator==(const __scheduler&) const noexcept -> bool = default; }; struct __reschedule_t { diff --git a/include/exec/sequence/any_sequence_of.hpp b/include/exec/sequence/any_sequence_of.hpp index 943c7f18b..b8d25af22 100644 --- a/include/exec/sequence/any_sequence_of.hpp +++ b/include/exec/sequence/any_sequence_of.hpp @@ -67,7 +67,8 @@ namespace exec { template requires sequence_receiver_of<_Rcvr, __item_types> && (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...) - friend const __t* tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Rcvr>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Rcvr>) noexcept + -> const __t* { static const __t __vtable_{ {__rcvr_next_vfun_fn<_Rcvr>{}(static_cast<_NextSigs*>(nullptr))}, {__rec::__rcvr_vfun_fn<_Rcvr>{}(static_cast<_Sigs*>(nullptr))}..., @@ -130,7 +131,7 @@ namespace exec { template _SetNext, same_as<__t> _Self, class _Sender> requires constructible_from<__item_sender, _Sender> - friend __void_sender tag_invoke(_SetNext, _Self& __self, _Sender&& __sndr) { + friend auto tag_invoke(_SetNext, _Self& __self, _Sender&& __sndr) -> __void_sender { return ( *static_cast*>(__self.__env_.__vtable_)->__fn_)( __self.__env_.__rcvr_, static_cast<_Sender&&>(__sndr)); @@ -160,7 +161,7 @@ namespace exec { } template _GetEnv, __decays_to<__t> _Self> - friend const __env_t& tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> const __env_t& { return __self.__env_; } }; @@ -177,7 +178,7 @@ namespace exec { using __receiver_ref_t = stdexec::__t<__next_receiver_ref<_Sigs, _ReceiverQueries>>; struct __t : public __query_vtable_t { - const __query_vtable_t& queries() const noexcept { + auto queries() const noexcept -> const __query_vtable_t& { return *this; } @@ -185,7 +186,8 @@ namespace exec { template requires sequence_sender_to<_Sender, __receiver_ref_t> - friend const __t* tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Sender>) noexcept { + friend auto tag_invoke(__create_vtable_t, __mtype<__t>, __mtype<_Sender>) noexcept + -> const __t* { static const __t __vtable_{ {*__create_vtable(__mtype<__query_vtable_t>{}, __mtype<_Sender>{})}, [](void* __object_pointer, __receiver_ref_t __receiver) @@ -244,10 +246,10 @@ namespace exec { using sender_concept = sequence_sender_t; __t(const __t&) = delete; - __t& operator=(const __t&) = delete; + auto operator=(const __t&) -> __t& = delete; __t(__t&&) = default; - __t& operator=(__t&&) = default; + auto operator=(__t&&) -> __t& = default; template <__not_decays_to<__t> _Sender> requires sequence_sender_to<_Sender, __receiver_ref_t> @@ -255,7 +257,7 @@ namespace exec { : __storage_{static_cast<_Sender&&>(__sndr)} { } - __immovable_operation_storage __connect(__receiver_ref_t __receiver) { + auto __connect(__receiver_ref_t __receiver) -> __immovable_operation_storage { return __storage_.__get_vtable()->subscribe_( __storage_.__get_object_pointer(), __receiver); } @@ -263,15 +265,15 @@ namespace exec { __unique_storage_t<__vtable_t> __storage_; template _Self, class _Rcvr> - friend stdexec::__t<__operation, true>> - tag_invoke(subscribe_t, _Self&& __self, _Rcvr __rcvr) { + friend auto tag_invoke(subscribe_t, _Self&& __self, _Rcvr __rcvr) + -> stdexec::__t<__operation, true>> { return {static_cast<_Self&&>(__self), static_cast<_Rcvr&&>(__rcvr)}; } using __env_t = stdexec::__t<__sender_env<_Sigs, _SenderQueries, _ReceiverQueries>>; template _GetEnv, __decays_to<__t> _Self> - friend __env_t tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> __env_t { return {__self.__storage_.__get_vtable(), __self.__storage_.__get_object_pointer()}; } }; @@ -291,7 +293,7 @@ namespace exec { template _GetEnv, std::same_as<__t> _Self> requires stdexec::__callable - friend __env_t tag_invoke(_GetEnv, const _Self& __self) noexcept { + friend auto tag_invoke(_GetEnv, const _Self& __self) noexcept -> __env_t { return stdexec::get_env(__self.__receiver_); } @@ -352,14 +354,14 @@ namespace exec { } template _Self, sequence_receiver_of _Rcvr> - friend subscribe_result_t<__sender_base, _Rcvr> - tag_invoke(exec::subscribe_t, _Self&& __self, _Rcvr __rcvr) { + friend auto tag_invoke(exec::subscribe_t, _Self&& __self, _Rcvr __rcvr) + -> subscribe_result_t<__sender_base, _Rcvr> { return exec::subscribe( static_cast<__sender_base&&>(__self.__sender_), static_cast<_Rcvr&&>(__rcvr)); } template _GetEnv, stdexec::__decays_to<__t> _Self> - friend stdexec::env_of_t<__sender_base> tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> stdexec::env_of_t<__sender_base> { return stdexec::get_env(__self.__sender_); } }; diff --git a/include/exec/sequence/empty_sequence.hpp b/include/exec/sequence/empty_sequence.hpp index deec1a9c9..008c2a6fd 100644 --- a/include/exec/sequence/empty_sequence.hpp +++ b/include/exec/sequence/empty_sequence.hpp @@ -57,7 +57,7 @@ namespace exec { }; struct empty_sequence_t { - __t<__sender> operator()() const noexcept { + auto operator()() const noexcept -> __t<__sender> { return {}; } }; diff --git a/include/exec/sequence/ignore_all_values.hpp b/include/exec/sequence/ignore_all_values.hpp index d9e73df16..ee63d1f91 100644 --- a/include/exec/sequence/ignore_all_values.hpp +++ b/include/exec/sequence/ignore_all_values.hpp @@ -111,7 +111,7 @@ namespace exec { } template _GetEnv, __decays_to<__t> _Self> - friend env_of_t<_ItemReceiver> tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> env_of_t<_ItemReceiver> { return stdexec::get_env(__self.__op_->__receiver_); } }; @@ -210,7 +210,7 @@ namespace exec { } template _GetEnv, __decays_to<__t> _Self> - friend env_of_t<_Receiver> tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> env_of_t<_Receiver> { return stdexec::get_env(__self.__op_->__receiver_); } }; @@ -275,8 +275,9 @@ namespace exec { template requires receiver_of<_Receiver, __completion_sigs<_Child>> && sequence_sender_to<_Child, __receiver_t<_Child>> - __operation_t<_Child> operator()(__ignore, __ignore, _Child&& __child) noexcept( - __nothrow_constructible_from<__operation_t<_Child>, _Child, _Receiver>) { + auto operator()(__ignore, __ignore, _Child&& __child) noexcept( + __nothrow_constructible_from<__operation_t<_Child>, _Child, _Receiver>) + -> __operation_t<_Child> { return {static_cast<_Child&&>(__child), static_cast<_Receiver&&>(__rcvr_)}; } }; @@ -289,7 +290,7 @@ namespace exec { __domain, __make_sexpr(__(), static_cast<_Sender&&>(__sndr))); } - constexpr __binder_back operator()() const noexcept { + constexpr auto operator()() const noexcept -> __binder_back { return {{}, {}, {}}; } }; diff --git a/include/exec/sequence/iterate.hpp b/include/exec/sequence/iterate.hpp index ce9fdc32e..998554381 100644 --- a/include/exec/sequence/iterate.hpp +++ b/include/exec/sequence/iterate.hpp @@ -108,7 +108,7 @@ namespace exec { } template _GetEnv, __decays_to<__t> _Self> - friend env_of_t<_Receiver> tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> env_of_t<_Receiver> { return stdexec::get_env(__self.__op_->__rcvr_); } }; @@ -211,7 +211,7 @@ namespace exec { return {}; } - static empty_env get_env(__ignore) noexcept { + static auto get_env(__ignore) noexcept -> empty_env { return {}; } }; diff --git a/include/exec/sequence/transform_each.hpp b/include/exec/sequence/transform_each.hpp index e35f4851c..7fcf44ba4 100644 --- a/include/exec/sequence/transform_each.hpp +++ b/include/exec/sequence/transform_each.hpp @@ -71,7 +71,7 @@ namespace exec { } template _GetEnv, __decays_to<__t> _Self> - friend env_of_t<_Receiver> tag_invoke(_GetEnv, _Self&& __self) noexcept { + friend auto tag_invoke(_GetEnv, _Self&& __self) noexcept -> env_of_t<_Receiver> { return stdexec::get_env(__self.__op_->__receiver_); } }; @@ -129,7 +129,7 @@ namespace exec { template requires stdexec::__callable<_Adaptor&, _Item> - stdexec::__msuccess __try_call(_Item*); + auto __try_call(_Item*) -> stdexec::__msuccess; template auto __try_calls(item_types<_Items...>*) -> decltype(( @@ -159,7 +159,8 @@ namespace exec { using __completion_sigs_t = __sequence_completion_signatures_of_t<__child_of<_Self>, _Env>; template _Self, class _Env> - static __completion_sigs_t<_Self, _Env> get_completion_signatures(_Self&&, _Env&&) noexcept { + static auto get_completion_signatures(_Self&&, _Env&&) noexcept + -> __completion_sigs_t<_Self, _Env> { return {}; } @@ -171,7 +172,7 @@ namespace exec { item_types_of_t<__child_of<_Self>, _Env>>; template _Self, class _Env> - static __item_types_t<_Self, _Env> get_item_types(_Self&&, _Env&&) noexcept { + static auto get_item_types(_Self&&, _Env&&) noexcept -> __item_types_t<_Self, _Env> { return {}; } @@ -194,7 +195,7 @@ namespace exec { } template _Sexpr> - static env_of_t<__child_of<_Sexpr>> get_env(const _Sexpr& __sexpr) noexcept { + static auto get_env(const _Sexpr& __sexpr) noexcept -> env_of_t<__child_of<_Sexpr>> { return __sexpr_apply(__sexpr, [](__ignore, __ignore, const _Child& __child) { return stdexec::get_env(__child); }); diff --git a/include/exec/sequence_senders.hpp b/include/exec/sequence_senders.hpp index 908152098..034b9e427 100644 --- a/include/exec/sequence_senders.hpp +++ b/include/exec/sequence_senders.hpp @@ -87,7 +87,7 @@ namespace exec { _Receiver __rcvr_; template _GetEnv, same_as<__t> _Self> - friend env_of_t<_Receiver> tag_invoke(_GetEnv, const _Self& __self) noexcept { + friend auto tag_invoke(_GetEnv, const _Self& __self) noexcept -> env_of_t<_Receiver> { return stdexec::get_env(__self.__rcvr_); } @@ -225,7 +225,7 @@ namespace exec { template requires stdexec::__callable - stdexec::__msuccess __try_item(_Item*); + auto __try_item(_Item*) -> stdexec::__msuccess; template auto __try_items(exec::item_types<_Items...>*) -> decltype(( @@ -413,7 +413,7 @@ namespace exec { } } - friend constexpr bool tag_invoke(forwarding_query_t, subscribe_t) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, subscribe_t) noexcept -> bool { return false; } }; diff --git a/include/exec/single_thread_context.hpp b/include/exec/single_thread_context.hpp index 6ecfa752d..a054c978b 100644 --- a/include/exec/single_thread_context.hpp +++ b/include/exec/single_thread_context.hpp @@ -40,7 +40,8 @@ namespace exec { return loop_.get_scheduler(); } - std::thread::id get_thread_id() const noexcept { + [[nodiscard]] + auto get_thread_id() const noexcept -> std::thread::id { return thread_.get_id(); } }; diff --git a/include/exec/static_thread_pool.hpp b/include/exec/static_thread_pool.hpp index 6162b1821..fb15f03c2 100644 --- a/include/exec/static_thread_pool.hpp +++ b/include/exec/static_thread_pool.hpp @@ -60,7 +60,8 @@ namespace exec { // even_share( 11, 2, 3); // -> [8, 11) -> 3 items // ``` template - std::pair even_share(Shape n, std::uint32_t rank, std::uint32_t size) noexcept { + auto even_share(Shape n, std::uint32_t rank, std::uint32_t size) noexcept + -> std::pair { STDEXEC_ASSERT(n >= 0); using ushape_t = std::make_unsigned_t; const auto avg_per_thread = static_cast(n) / size; @@ -134,7 +135,7 @@ namespace exec { } } - __intrusive_queue<&task_base::next> pop_all_reversed(std::size_t tid) noexcept { + auto pop_all_reversed(std::size_t tid) noexcept -> __intrusive_queue<&task_base::next> { remote_queue* head = head_.load(std::memory_order_acquire); __intrusive_queue<&task_base::next> tasks{}; while (head != nullptr) { @@ -144,7 +145,7 @@ namespace exec { return tasks; } - remote_queue* get() { + auto get() -> remote_queue* { thread_local std::thread::id this_id = std::this_thread::get_id(); remote_queue* head = head_.load(std::memory_order_acquire); remote_queue* queue = head; @@ -154,7 +155,7 @@ namespace exec { } queue = queue->next_; } - remote_queue* new_head = new remote_queue{head, nthreads_}; + auto* new_head = new remote_queue{head, nthreads_}; while (!head_.compare_exchange_weak(head, new_head, std::memory_order_acq_rel)) { new_head->next_ = head; } @@ -246,7 +247,7 @@ namespace exec { #if STDEXEC_HAS_STD_RANGES() struct transform_iterate { template - __t> operator()(exec::iterate_t, Range&& range) { + auto operator()(exec::iterate_t, Range&& range) -> __t> { return {static_cast(range), pool_}; } @@ -317,7 +318,7 @@ namespace exec { struct scheduler { using __t = scheduler; using __id = scheduler; - bool operator==(const scheduler&) const = default; + auto operator==(const scheduler&) const -> bool = default; private: template @@ -350,17 +351,18 @@ namespace exec { remote_queue* queue_; template - friend static_thread_pool_::scheduler - tag_invoke(get_completion_scheduler_t, const env& self) noexcept { + friend auto tag_invoke(get_completion_scheduler_t, const env& self) noexcept + -> static_thread_pool_::scheduler { return self.make_scheduler_(); } - static_thread_pool_::scheduler make_scheduler_() const { + [[nodiscard]] + auto make_scheduler_() const -> static_thread_pool_::scheduler { return static_thread_pool_::scheduler{pool_, *queue_}; } }; - friend env tag_invoke(get_env_t, const sender& self) noexcept { + friend auto tag_invoke(get_env_t, const sender& self) noexcept -> env { return env{self.pool_, self.queue_}; } @@ -383,20 +385,22 @@ namespace exec { nodemask constraints_{}; }; - sender make_sender_() const { + [[nodiscard]] + auto make_sender_() const -> sender { return sender{*pool_, queue_, thread_idx_, nodemask_}; } - friend sender tag_invoke(schedule_t, const scheduler& sch) noexcept { + friend auto tag_invoke(schedule_t, const scheduler& sch) noexcept -> sender { return sch.make_sender_(); } - friend forward_progress_guarantee - tag_invoke(get_forward_progress_guarantee_t, const static_thread_pool_&) noexcept { + friend auto + tag_invoke(get_forward_progress_guarantee_t, const static_thread_pool_&) noexcept + -> forward_progress_guarantee { return forward_progress_guarantee::parallel; } - friend domain tag_invoke(get_domain_t, scheduler) noexcept { + friend auto tag_invoke(get_domain_t, scheduler) noexcept -> domain { return {}; } @@ -434,19 +438,19 @@ namespace exec { std::size_t thread_idx_{std::numeric_limits::max()}; }; - scheduler get_scheduler() noexcept { + auto get_scheduler() noexcept -> scheduler { return scheduler{*this}; } - scheduler get_scheduler_on_thread(std::size_t threadIndex) noexcept { + auto get_scheduler_on_thread(std::size_t threadIndex) noexcept -> scheduler { return scheduler{*this, *get_remote_queue(), threadIndex}; } - scheduler get_constrained_scheduler(const nodemask& constraints) noexcept { + auto get_constrained_scheduler(const nodemask& constraints) noexcept -> scheduler { return scheduler{*this, *get_remote_queue(), constraints}; } - remote_queue* get_remote_queue() noexcept { + auto get_remote_queue() noexcept -> remote_queue* { remote_queue* queue = remotes_.get(); std::size_t index = 0; for (std::thread& t: threads_) { @@ -461,11 +465,13 @@ namespace exec { void request_stop() noexcept; - std::uint32_t available_parallelism() const { + [[nodiscard]] + auto available_parallelism() const -> std::uint32_t { return threadCount_; } - bwos_params params() const { + [[nodiscard]] + auto params() const -> bwos_params { return params_; } @@ -496,15 +502,17 @@ namespace exec { , numa_node_(numa_node) { } - task_base* try_steal() noexcept { + auto try_steal() noexcept -> task_base* { return queue_->steal_front(); } - std::uint32_t index() const noexcept { + [[nodiscard]] + auto index() const noexcept -> std::uint32_t { return index_; } - int numa_node() const noexcept { + [[nodiscard]] + auto numa_node() const noexcept -> int { return numa_node_; } @@ -547,11 +555,11 @@ namespace exec { rng_.seed(rd); } - pop_result pop(); + auto pop() -> pop_result; void push_local(task_base* task); void push_local(__intrusive_queue<&task_base::next>&& tasks); - bool notify(); + auto notify() -> bool; void request_stop(); void victims(const std::vector& victims) { @@ -567,15 +575,17 @@ namespace exec { } } - std::uint32_t index() const noexcept { + [[nodiscard]] + auto index() const noexcept -> std::uint32_t { return index_; } - int numa_node() const noexcept { + [[nodiscard]] + auto numa_node() const noexcept -> int { return numa_node_; } - workstealing_victim as_victim() noexcept { + auto as_victim() noexcept -> workstealing_victim { return workstealing_victim{&local_queue_, index_, numa_node_}; } @@ -587,11 +597,11 @@ namespace exec { notified }; - pop_result try_pop(); - pop_result try_remote(); - pop_result try_steal(std::span victims); - pop_result try_steal_near(); - pop_result try_steal_any(); + auto try_pop() -> pop_result; + auto try_remote() -> pop_result; + auto try_steal(std::span victims) -> pop_result; + auto try_steal_near() -> pop_result; + auto try_steal_any() -> pop_result; void notify_one_sleeping(); void set_stealing(); @@ -625,19 +635,22 @@ namespace exec { int numa_node; std::size_t thread_index; - friend bool operator<( + friend auto operator<( const thread_index_by_numa_node& lhs, - const thread_index_by_numa_node& rhs) noexcept { + const thread_index_by_numa_node& rhs) noexcept -> bool { return lhs.numa_node < rhs.numa_node; } }; std::vector threadIndexByNumaNode_; - std::size_t num_threads(int numa) const noexcept; - std::size_t num_threads(nodemask constraints) const noexcept; - std::size_t get_thread_index(int numa, std::size_t index) const noexcept; - std::size_t random_thread_index_with_constraints(const nodemask& contraints) noexcept; + [[nodiscard]] + auto num_threads(int numa) const noexcept -> std::size_t; + [[nodiscard]] + auto num_threads(nodemask constraints) const noexcept -> std::size_t; + [[nodiscard]] + auto get_thread_index(int numa, std::size_t index) const noexcept -> std::size_t; + auto random_thread_index_with_constraints(const nodemask& contraints) noexcept -> std::size_t; }; inline static_thread_pool_::static_thread_pool_() @@ -717,7 +730,7 @@ namespace exec { this->enqueue(*get_remote_queue(), task, constraints); } - inline std::size_t static_thread_pool_::num_threads(int numa) const noexcept { + inline auto static_thread_pool_::num_threads(int numa) const noexcept -> std::size_t { thread_index_by_numa_node key{numa, 0}; auto it = std::lower_bound(threadIndexByNumaNode_.begin(), threadIndexByNumaNode_.end(), key); if (it == threadIndexByNumaNode_.end()) { @@ -727,9 +740,9 @@ namespace exec { return static_cast(std::distance(it, itEnd)); } - inline std::size_t static_thread_pool_::num_threads(nodemask constraints) const noexcept { - const std::size_t nNodes = static_cast( - threadIndexByNumaNode_.back().numa_node + 1); + inline auto static_thread_pool_::num_threads(nodemask constraints) const noexcept + -> std::size_t { + const auto nNodes = static_cast(threadIndexByNumaNode_.back().numa_node + 1); std::size_t nThreads = 0; for (std::size_t nodeIndex = 0; nodeIndex < nNodes; ++nodeIndex) { if (!constraints[nodeIndex]) { @@ -740,8 +753,9 @@ namespace exec { return nThreads; } - inline std::size_t - static_thread_pool_::get_thread_index(int nodeIndex, std::size_t threadIndex) const noexcept { + inline auto + static_thread_pool_::get_thread_index(int nodeIndex, std::size_t threadIndex) const noexcept + -> std::size_t { thread_index_by_numa_node key{nodeIndex, 0}; auto it = std::lower_bound(threadIndexByNumaNode_.begin(), threadIndexByNumaNode_.end(), key); STDEXEC_ASSERT(it != threadIndexByNumaNode_.end()); @@ -749,8 +763,8 @@ namespace exec { return it->thread_index; } - inline std::size_t static_thread_pool_::random_thread_index_with_constraints( - const nodemask& constraints) noexcept { + inline auto static_thread_pool_::random_thread_index_with_constraints( + const nodemask& constraints) noexcept -> std::size_t { thread_local std::uint64_t startIndex{std::uint64_t(std::random_device{}())}; startIndex += 1; std::size_t targetIndex = startIndex % threadCount_; @@ -778,7 +792,7 @@ namespace exec { remote_queue* correct_queue = this_id == queue.id_ ? &queue : get_remote_queue(); std::size_t idx = correct_queue->index_; if (idx < threadStates_.size()) { - std::size_t this_node = static_cast(threadStates_[idx]->numa_node()); + auto this_node = static_cast(threadStates_[idx]->numa_node()); if (constraints[this_node]) { threadStates_[idx]->push_local(task); return; @@ -817,7 +831,7 @@ namespace exec { remote_queue* correct_queue = this_id == queue.id_ ? &queue : get_remote_queue(); std::size_t idx = correct_queue->index_; if (idx < threadStates_.size()) { - std::size_t this_node = static_cast(threadStates_[idx]->numa_node()); + auto this_node = static_cast(threadStates_[idx]->numa_node()); if (constraints[this_node]) { threadStates_[idx]->push_local(std::move(tasks)); return; @@ -848,8 +862,8 @@ namespace exec { tmp.clear(); } - inline static_thread_pool_::thread_state::pop_result - static_thread_pool_::thread_state::try_remote() { + inline auto static_thread_pool_::thread_state::try_remote() + -> static_thread_pool_::thread_state::pop_result { pop_result result{nullptr, index_}; __intrusive_queue<&task_base::next> remotes = pool_->remotes_.pop_all_reversed(index_); pending_queue_.append(std::move(remotes)); @@ -860,8 +874,8 @@ namespace exec { return result; } - inline static_thread_pool_::thread_state::pop_result - static_thread_pool_::thread_state::try_pop() { + inline auto static_thread_pool_::thread_state::try_pop() + -> static_thread_pool_::thread_state::pop_result { pop_result result{nullptr, index_}; result.task = local_queue_.pop_back(); if (result.task) [[likely]] { @@ -870,8 +884,8 @@ namespace exec { return try_remote(); } - inline static_thread_pool_::thread_state::pop_result - static_thread_pool_::thread_state::try_steal(std::span victims) { + inline auto static_thread_pool_::thread_state::try_steal(std::span victims) + -> static_thread_pool_::thread_state::pop_result { if (victims.empty()) { return {nullptr, index_}; } @@ -882,13 +896,13 @@ namespace exec { return {v.try_steal(), v.index()}; } - inline static_thread_pool_::thread_state::pop_result - static_thread_pool_::thread_state::try_steal_near() { + inline auto static_thread_pool_::thread_state::try_steal_near() + -> static_thread_pool_::thread_state::pop_result { return try_steal(near_victims_); } - inline static_thread_pool_::thread_state::pop_result - static_thread_pool_::thread_state::try_steal_any() { + inline auto static_thread_pool_::thread_state::try_steal_any() + -> static_thread_pool_::thread_state::pop_result { return try_steal(all_victims_); } @@ -927,7 +941,8 @@ namespace exec { } } - inline static_thread_pool_::thread_state::pop_result static_thread_pool_::thread_state::pop() { + inline auto static_thread_pool_::thread_state::pop() + -> static_thread_pool_::thread_state::pop_result { pop_result result = try_pop(); while (!result.task) { set_stealing(); @@ -967,7 +982,7 @@ namespace exec { return result; } - inline bool static_thread_pool_::thread_state::notify() { + inline auto static_thread_pool_::thread_state::notify() -> bool { if (state_.exchange(state::notified, std::memory_order_relaxed) == state::sleeping) { { std::lock_guard lock{mut_}; @@ -1074,7 +1089,7 @@ namespace exec { template <__decays_to<__t> Self, receiver Receiver> requires receiver_of>> - friend bulk_op_state_t // + friend auto // tag_invoke(connect_t, Self&& self, Receiver rcvr) // noexcept(__nothrow_constructible_from< bulk_op_state_t, @@ -1082,7 +1097,7 @@ namespace exec { Shape, Fun, Sender, - Receiver>) { + Receiver>) -> bulk_op_state_t { return bulk_op_state_t{ self.pool_, self.shape_, @@ -1175,7 +1190,8 @@ namespace exec { std::exception_ptr exception_; std::vector tasks_; - std::uint32_t num_agents_required() const { + [[nodiscard]] + auto num_agents_required() const -> std::uint32_t { return static_cast( std::min(shape_, static_cast(pool_.available_parallelism()))); } @@ -1562,8 +1578,8 @@ namespace exec { namespace _pool_ { struct schedule_all_t { template - stdexec::__t>> - operator()(static_thread_pool& pool, Range&& range) const { + auto operator()(static_thread_pool& pool, Range&& range) const + -> stdexec::__t>> { return {static_cast(range), pool}; } }; diff --git a/include/exec/task.hpp b/include/exec/task.hpp index 4b7a621de..eb1bb8a70 100644 --- a/include/exec/task.hpp +++ b/include/exec/task.hpp @@ -100,8 +100,8 @@ namespace exec { __scheduler_{exec::inline_scheduler{}}; in_place_stop_token __stop_token_; - friend const __any_scheduler& - tag_invoke(get_scheduler_t, const __default_task_context_impl& __self) noexcept + friend auto tag_invoke(get_scheduler_t, const __default_task_context_impl& __self) noexcept + -> const __any_scheduler& requires(__with_scheduler) { return __self.__scheduler_; @@ -120,7 +120,8 @@ namespace exec { : __scheduler_{static_cast<_Scheduler&&>(__scheduler)} { } - bool stop_requested() const noexcept { + [[nodiscard]] + auto stop_requested() const noexcept -> bool { return __stop_token_.stop_requested(); } @@ -308,7 +309,7 @@ namespace exec { }; template - __wrap<_Scheduler> operator()(_Scheduler __sched) const noexcept { + auto operator()(_Scheduler __sched) const noexcept -> __wrap<_Scheduler> { return {static_cast<_Scheduler&&>(__sched)}; } }; @@ -334,12 +335,12 @@ namespace exec { private: struct __final_awaitable { - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } - static __coro::coroutine_handle<> await_suspend( - __coro::coroutine_handle<__promise> __h) noexcept { + static auto await_suspend(__coro::coroutine_handle<__promise> __h) noexcept + -> __coro::coroutine_handle<> { return __h.promise().continuation().handle(); } @@ -350,19 +351,20 @@ namespace exec { struct __promise : __promise_base<_Ty> , with_awaitable_senders<__promise> { - basic_task get_return_object() noexcept { + auto get_return_object() noexcept -> basic_task { return basic_task(__coro::coroutine_handle<__promise>::from_promise(*this)); } - __coro::suspend_always initial_suspend() noexcept { + auto initial_suspend() noexcept -> __coro::suspend_always { return {}; } - __final_awaitable final_suspend() noexcept { + auto final_suspend() noexcept -> __final_awaitable { return {}; } - __task::disposition disposition() const noexcept { + [[nodiscard]] + auto disposition() const noexcept -> __task::disposition { return static_cast<__task::disposition>(this->__data_.index()); } @@ -372,7 +374,7 @@ namespace exec { template requires __scheduler_provider<_Context> - decltype(auto) await_transform(_Awaitable&& __awaitable) noexcept { + auto await_transform(_Awaitable&& __awaitable) noexcept -> decltype(auto) { // TODO: If we have a complete-where-it-starts query then we can optimize // this to avoid the reschedule return as_awaitable( @@ -381,8 +383,8 @@ namespace exec { template requires __scheduler_provider<_Context> - decltype(auto) - await_transform(__reschedule_coroutine_on::__wrap<_Scheduler> __box) noexcept { + auto await_transform(__reschedule_coroutine_on::__wrap<_Scheduler> __box) noexcept + -> decltype(auto) { if (!std::exchange(__rescheduled_, true)) { // Create a cleanup action that transitions back onto the current scheduler: auto __sched = get_scheduler(__context_); @@ -398,14 +400,14 @@ namespace exec { } template - decltype(auto) await_transform(_Awaitable&& __awaitable) noexcept { + auto await_transform(_Awaitable&& __awaitable) noexcept -> decltype(auto) { return with_awaitable_senders<__promise>::await_transform( static_cast<_Awaitable&&>(__awaitable)); } using __context_t = typename _Context::template promise_context_t<__promise>; - friend const __context_t& tag_invoke(get_env_t, const __promise& __self) noexcept { + friend auto tag_invoke(get_env_t, const __promise& __self) noexcept -> const __context_t& { return __self.__context_; } @@ -423,13 +425,13 @@ namespace exec { __coro_.destroy(); } - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } template - __coro::coroutine_handle<> - await_suspend(__coro::coroutine_handle<_ParentPromise2> __parent) noexcept { + auto await_suspend(__coro::coroutine_handle<_ParentPromise2> __parent) noexcept + -> __coro::coroutine_handle<> { static_assert(__one_of<_ParentPromise, _ParentPromise2, void>); __context_.emplace(__coro_.promise().__context_, __parent.promise()); __coro_.promise().set_continuation(__parent); @@ -440,7 +442,7 @@ namespace exec { return __coro_; } - _Ty await_resume() { + auto await_resume() -> _Ty { __context_.reset(); scope_guard __on_exit{[this]() noexcept { std::exchange(__coro_, {}).destroy(); @@ -458,13 +460,13 @@ namespace exec { awaiter_context_t<__promise, _ParentPromise>, __promise&, _ParentPromise&> - friend __task_awaitable<_ParentPromise> - tag_invoke(as_awaitable_t, basic_task&& __self, _ParentPromise&) noexcept { + friend auto tag_invoke(as_awaitable_t, basic_task&& __self, _ParentPromise&) noexcept + -> __task_awaitable<_ParentPromise> { return __task_awaitable<_ParentPromise>{std::exchange(__self.__coro_, {})}; } // Make this task generally awaitable: - friend __task_awaitable<> operator co_await(basic_task && __self) noexcept + friend auto operator co_await(basic_task&& __self) noexcept -> __task_awaitable<> requires __mvalid { return __task_awaitable<>{std::exchange(__self.__coro_, {})}; diff --git a/include/exec/trampoline_scheduler.hpp b/include/exec/trampoline_scheduler.hpp index 5b5adfaab..273984bea 100644 --- a/include/exec/trampoline_scheduler.hpp +++ b/include/exec/trampoline_scheduler.hpp @@ -137,8 +137,8 @@ namespace exec { } template _Receiver> - __operation_t<_Receiver> __make_operation(_Receiver __rcvr) const - noexcept(__nothrow_decay_copyable<_Receiver>) { + auto __make_operation(_Receiver __rcvr) const noexcept(__nothrow_decay_copyable<_Receiver>) + -> __operation_t<_Receiver> { return __operation_t<_Receiver>{static_cast<_Receiver&&>(__rcvr), __max_recursion_depth_}; } @@ -148,25 +148,26 @@ namespace exec { return __self.__make_operation(static_cast<_Receiver&&>(__rcvr)); } - friend __scheduler - tag_invoke(get_completion_scheduler_t, __schedule_sender __self) noexcept { + friend auto + tag_invoke(get_completion_scheduler_t, __schedule_sender __self) noexcept + -> __scheduler { return __scheduler{__self.__max_recursion_depth_}; } - friend const __schedule_sender& - tag_invoke(get_env_t, const __schedule_sender& __self) noexcept { + friend auto tag_invoke(get_env_t, const __schedule_sender& __self) noexcept + -> const __schedule_sender& { return __self; } std::size_t __max_recursion_depth_; }; - friend __schedule_sender tag_invoke(schedule_t, __scheduler __self) noexcept { + friend auto tag_invoke(schedule_t, __scheduler __self) noexcept -> __schedule_sender { return __schedule_sender{__self.__max_recursion_depth_}; } public: - bool operator==(const __scheduler&) const noexcept = default; + auto operator==(const __scheduler&) const noexcept -> bool = default; }; template diff --git a/include/exec/variant_sender.hpp b/include/exec/variant_sender.hpp index 4f76cb4e7..1fe773da1 100644 --- a/include/exec/variant_sender.hpp +++ b/include/exec/variant_sender.hpp @@ -58,8 +58,8 @@ namespace exec { _Receiver __r; template - stdexec::__t<__operation_state<__id<_Receiver>, __copy_cvref_t<_Self, _SenderIds>...>> - operator()(_Sender&& __s) { + auto operator()(_Sender&& __s) + -> stdexec::__t<__operation_state<__id<_Receiver>, __copy_cvref_t<_Self, _SenderIds>...>> { return {static_cast<_Sender&&>(__s), static_cast<_Receiver&&>(__r)}; } }; @@ -67,26 +67,25 @@ namespace exec { class __t : private std::variant...> { using __variant_t = std::variant...>; - __variant_t&& base() && noexcept { + auto base() && noexcept -> __variant_t&& { return std::move(*this); } - __variant_t& base() & noexcept { + auto base() & noexcept -> __variant_t& { return *this; } - const __variant_t& base() const & noexcept { + auto base() const & noexcept -> const __variant_t& { return *this; } template <__decays_to<__t> _Self, receiver _Receiver> requires(sender_to<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, _Receiver> && ...) - friend stdexec::__t<__operation_state< - stdexec::__id<_Receiver>, - __cvref_id<_Self, stdexec::__t<_SenderIds>>...>> - tag_invoke(connect_t, _Self&& __self, _Receiver __r) noexcept( - (__nothrow_connectable<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, _Receiver> - && ...)) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __r) noexcept(( + __nothrow_connectable<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, _Receiver> && ...)) + -> stdexec::__t<__operation_state< + stdexec::__id<_Receiver>, + __cvref_id<_Self, stdexec::__t<_SenderIds>>...>> { return std::visit( __visitor<_Self, _Receiver>{static_cast<_Receiver&&>(__r)}, static_cast<_Self&&>(__self).base()); diff --git a/include/exec/when_any.hpp b/include/exec/when_any.hpp index 168f8eee4..4e60d8747 100644 --- a/include/exec/when_any.hpp +++ b/include/exec/when_any.hpp @@ -38,7 +38,7 @@ namespace exec { using __env_t = __env::__join_t<__env::__with, _BaseEnv>; template - __decayed_tuple<_Ret, _Args...> __signature_to_tuple_(_Ret (*)(_Args...)); + auto __signature_to_tuple_(_Ret (*)(_Args...)) -> __decayed_tuple<_Ret, _Args...>; template using __signature_to_tuple_t = decltype(__signature_to_tuple_(static_cast<_Sig*>(nullptr))); @@ -175,7 +175,8 @@ namespace exec { __self.__op_->notify(_CPO{}, static_cast<_Args&&>(__args)...); } - friend __env_t> tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept + -> __env_t> { auto __token = __env::__with(__self.__op_->__stop_source_.get_token(), get_stop_token); return __env::__join(std::move(__token), get_env(__self.__op_->__receiver_)); } @@ -258,8 +259,9 @@ namespace exec { requires( sender_to<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, __receiver_t<_Receiver>> && ...) - friend __op_t<_Receiver> tag_invoke(connect_t, _Self&& __self, _Receiver&& __rcvr) // - noexcept(__nothrow_constructible_from<__op_t<_Receiver>, _Self&&, _Receiver&&>) { + friend auto tag_invoke(connect_t, _Self&& __self, _Receiver&& __rcvr) // + noexcept(__nothrow_constructible_from<__op_t<_Receiver>, _Self&&, _Receiver&&>) + -> __op_t<_Receiver> { return __op_t<_Receiver>{ static_cast<_Self&&>(__self).__senders_, static_cast<_Receiver&&>(__rcvr)}; } @@ -280,8 +282,8 @@ namespace exec { template requires(sizeof...(_Senders) > 0 && sender<__sender_t<_Senders...>>) - __sender_t<_Senders...> operator()(_Senders&&... __senders) const - noexcept((__nothrow_decay_copyable<_Senders> && ...)) { + auto operator()(_Senders&&... __senders) const + noexcept((__nothrow_decay_copyable<_Senders> && ...)) -> __sender_t<_Senders...> { return __sender_t<_Senders...>(static_cast<_Senders&&>(__senders)...); } }; diff --git a/include/stdexec/__detail/__basic_sender.hpp b/include/stdexec/__detail/__basic_sender.hpp index 7e7eae857..ace8a9d55 100644 --- a/include/stdexec/__detail/__basic_sender.hpp +++ b/include/stdexec/__detail/__basic_sender.hpp @@ -280,7 +280,7 @@ namespace stdexec { , __state_(__sexpr_impl<__tag_t>::get_state(static_cast<_Sexpr&&>(__sndr), __rcvr_)) { } - _Receiver& __rcvr() & noexcept { + auto __rcvr() & noexcept -> _Receiver& { return __rcvr_; } }; @@ -314,11 +314,11 @@ namespace stdexec { struct __enable_receiver_from_this { using __op_base_t = __op_base<_Sexpr, _Receiver>; - decltype(auto) __receiver() noexcept { + auto __receiver() noexcept -> decltype(auto) { using __derived_t = decltype(__op_base_t::__state_); - __derived_t* __derived = static_cast<__derived_t*>(this); + auto* __derived = static_cast<__derived_t*>(this); constexpr std::size_t __offset = offsetof(__op_base_t, __state_); - __op_base_t* __base = reinterpret_cast<__op_base_t*>( + auto* __base = reinterpret_cast<__op_base_t*>( reinterpret_cast(__derived) - __offset); return __base->__rcvr(); } @@ -501,7 +501,7 @@ namespace stdexec { using __tag_t = typename __desc_t::__tag; using __captures_t = __minvoke<__desc_t, __q<__detail::__captures_t>>; - static constexpr bool __is_non_dependent() noexcept { + static constexpr auto __is_non_dependent() noexcept -> bool { return __v<__minvoke<__desc_t, __q<__detail::__is_non_dependent_t>>>; } diff --git a/include/stdexec/__detail/__config.hpp b/include/stdexec/__detail/__config.hpp index 987b00e5e..04b2060f0 100644 --- a/include/stdexec/__detail/__config.hpp +++ b/include/stdexec/__detail/__config.hpp @@ -37,9 +37,12 @@ #define STDEXEC_EVAL(_MACRO, ...) _MACRO(__VA_ARGS__) #define STDEXEC_EAT(...) -#define STDEXEC_NOT(_XP) STDEXEC_CAT(STDEXEC_NOT_, _XP) -#define STDEXEC_NOT_0 1 -#define STDEXEC_NOT_1 0 +#define STDEXEC_NOT(_XP) STDEXEC_CAT(STDEXEC_NOT_, _XP) + +enum { + STDEXEC_NOT_0 = 1, + STDEXEC_NOT_1 = 0 +}; #define STDEXEC_IIF_0(_YP, ...) __VA_ARGS__ #define STDEXEC_IIF_1(_YP, ...) _YP diff --git a/include/stdexec/__detail/__domain.hpp b/include/stdexec/__detail/__domain.hpp index e637545e8..b141815a8 100644 --- a/include/stdexec/__detail/__domain.hpp +++ b/include/stdexec/__detail/__domain.hpp @@ -45,7 +45,7 @@ namespace stdexec { struct __legacy_customization { template requires __has_legacy_c11n<_Tag, _Data, _Children...> - decltype(auto) operator()(_Tag, _Data&& __data, _Children&&... __children) const { + auto operator()(_Tag, _Data&& __data, _Children&&... __children) const -> decltype(auto) { return __legacy_c11n_fn<_Tag, _Data, _Children...>()( static_cast<_Data&&>(__data), static_cast<_Children&&>(__children)...); } @@ -125,7 +125,7 @@ namespace stdexec { } template - decltype(auto) transform_env(_Sender&& __sndr, _Env&& __env) const noexcept { + auto transform_env(_Sender&& __sndr, _Env&& __env) const noexcept -> decltype(auto) { if constexpr (__domain::__has_default_transform_env<_Sender, _Env>) { return tag_of_t<_Sender>().transform_env( static_cast<_Sender&&>(__sndr), static_cast<_Env&&>(__env)); @@ -225,13 +225,13 @@ namespace stdexec { namespace __domain { struct __common_domain_fn { - static default_domain __common_domain() noexcept { + static auto __common_domain() noexcept -> default_domain { return {}; } template requires __all_of<_Domain, _OtherDomains...> - static _Domain __common_domain(_Domain __domain, _OtherDomains...) noexcept { + static auto __common_domain(_Domain __domain, _OtherDomains...) noexcept -> _Domain { return static_cast<_Domain&&>(__domain); } diff --git a/include/stdexec/__detail/__env.hpp b/include/stdexec/__detail/__env.hpp index be8e0bca7..160309590 100644 --- a/include/stdexec/__detail/__env.hpp +++ b/include/stdexec/__detail/__env.hpp @@ -48,7 +48,7 @@ namespace stdexec { namespace __queries { struct forwarding_query_t { template - constexpr bool operator()(_Query __query) const noexcept { + constexpr auto operator()(_Query __query) const noexcept -> bool { if constexpr (tag_invocable) { return tag_invoke(*this, static_cast<_Query&&>(__query)); } else if constexpr (std::derived_from<_Query, forwarding_query_t>) { @@ -77,14 +77,14 @@ namespace stdexec { struct execute_may_block_caller_t : __query { template requires tag_invocable> - constexpr bool operator()(_Tp&& __t) const noexcept { + constexpr auto operator()(_Tp&& __t) const noexcept -> bool { static_assert( same_as>>); static_assert(nothrow_tag_invocable>); return tag_invoke(execute_may_block_caller_t{}, std::as_const(__t)); } - constexpr bool operator()(auto&&) const noexcept { + constexpr auto operator()(auto&&) const noexcept -> bool { return true; } }; @@ -98,7 +98,7 @@ namespace stdexec { return tag_invoke(get_forward_progress_guarantee_t{}, std::as_const(__t)); } - constexpr stdexec::forward_progress_guarantee operator()(auto&&) const noexcept { + constexpr auto operator()(auto&&) const noexcept -> stdexec::forward_progress_guarantee { return stdexec::forward_progress_guarantee::weakly_parallel; } }; @@ -109,13 +109,14 @@ namespace stdexec { template requires tag_invocable<__has_algorithm_customizations_t, __cref_t<_Tp>> - constexpr __result_t<_Tp> operator()(_Tp&&) const noexcept(noexcept(__result_t<_Tp>{})) { + constexpr auto operator()(_Tp&&) const noexcept(noexcept(__result_t<_Tp>{})) + -> __result_t<_Tp> { using _Boolean = tag_invoke_result_t<__has_algorithm_customizations_t, __cref_t<_Tp>>; static_assert(_Boolean{} ? true : true); // must be contextually convertible to bool return _Boolean{}; } - constexpr std::false_type operator()(auto&&) const noexcept { + constexpr auto operator()(auto&&) const noexcept -> std::false_type { return {}; } }; @@ -125,7 +126,8 @@ namespace stdexec { concept __allocator_c = true; struct get_scheduler_t : __query { - friend constexpr bool tag_invoke(forwarding_query_t, const get_scheduler_t&) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, const get_scheduler_t&) noexcept + -> bool { return true; } @@ -139,8 +141,8 @@ namespace stdexec { }; struct get_delegatee_scheduler_t : __query { - friend constexpr bool - tag_invoke(forwarding_query_t, const get_delegatee_scheduler_t&) noexcept { + friend constexpr auto + tag_invoke(forwarding_query_t, const get_delegatee_scheduler_t&) noexcept -> bool { return true; } @@ -154,7 +156,8 @@ namespace stdexec { }; struct get_allocator_t : __query { - friend constexpr bool tag_invoke(forwarding_query_t, const get_allocator_t&) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, const get_allocator_t&) noexcept + -> bool { return true; } @@ -172,12 +175,13 @@ namespace stdexec { }; struct get_stop_token_t : __query { - friend constexpr bool tag_invoke(forwarding_query_t, const get_stop_token_t&) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, const get_stop_token_t&) noexcept + -> bool { return true; } template - never_stop_token operator()(const _Env&) const noexcept { + auto operator()(const _Env&) const noexcept -> never_stop_token { return {}; } @@ -201,8 +205,8 @@ namespace stdexec { template <__completion_tag _CPO> struct get_completion_scheduler_t : __query> { - friend constexpr bool - tag_invoke(forwarding_query_t, const get_completion_scheduler_t<_CPO>&) noexcept { + friend constexpr auto + tag_invoke(forwarding_query_t, const get_completion_scheduler_t<_CPO>&) noexcept -> bool { return true; } @@ -225,7 +229,7 @@ namespace stdexec { return tag_invoke(get_domain_t{}, __ty); } - friend constexpr bool tag_invoke(forwarding_query_t, get_domain_t) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, get_domain_t) noexcept -> bool { return true; } }; @@ -290,7 +294,7 @@ namespace stdexec { } template - constexpr empty_env operator()(const _EnvProvider&) const noexcept { + constexpr auto operator()(const _EnvProvider&) const noexcept -> empty_env { return {}; } @@ -300,7 +304,7 @@ namespace stdexec { template struct __promise { template - _Ty&& await_transform(_Ty&& __value) noexcept { + auto await_transform(_Ty&& __value) noexcept -> _Ty&& { return static_cast<_Ty&&>(__value); } @@ -412,7 +416,7 @@ namespace stdexec { struct __without_fn { template - constexpr decltype(auto) operator()(_Env&& __env, _Tag, _Tags...) const noexcept { + constexpr auto operator()(_Env&& __env, _Tag, _Tags...) const noexcept -> decltype(auto) { if constexpr (tag_invocable<_Tag, _Env> || (tag_invocable<_Tags, _Env> || ...)) { return __without_{__ref_fn()(static_cast<_Env&&>(__env)), _Tag(), _Tags()...}; } else { @@ -472,41 +476,41 @@ namespace stdexec { return __fwd{static_cast(env)}; } - empty_env operator()(empty_env) const { + auto operator()(empty_env) const -> empty_env { return {}; } }; struct __join_fn { - empty_env operator()() const { + auto operator()() const -> empty_env { return {}; } template - _Env operator()(_Env&& __env) const { + auto operator()(_Env&& __env) const -> _Env { return static_cast<_Env&&>(__env); } - empty_env operator()(empty_env) const { + auto operator()(empty_env) const -> empty_env { return {}; } template - _Env operator()(_Env&& __env, empty_env) const { + auto operator()(_Env&& __env, empty_env) const -> _Env { return static_cast<_Env&&>(__env); } - empty_env operator()(empty_env, empty_env) const { + auto operator()(empty_env, empty_env) const -> empty_env { return {}; } template - decltype(auto) operator()(empty_env, Rest&&... rest) const { + auto operator()(empty_env, Rest&&... rest) const -> decltype(auto) { return __fwd_fn()(__join_fn()(static_cast(rest)...)); } template - decltype(auto) operator()(First&& first, Rest&&... rest) const { + auto operator()(First&& first, Rest&&... rest) const -> decltype(auto) { return __joined{ __fwd_fn()(__join_fn()(static_cast(rest)...)), static_cast(first)}; } diff --git a/include/stdexec/__detail/__intrusive_ptr.hpp b/include/stdexec/__detail/__intrusive_ptr.hpp index 79ef68f4a..c6626c649 100644 --- a/include/stdexec/__detail/__intrusive_ptr.hpp +++ b/include/stdexec/__detail/__intrusive_ptr.hpp @@ -39,8 +39,8 @@ namespace stdexec { template struct __enable_intrusive_from_this { - __intrusive_ptr<_Ty> __intrusive_from_this() noexcept; - __intrusive_ptr __intrusive_from_this() const noexcept; + auto __intrusive_from_this() noexcept -> __intrusive_ptr<_Ty>; + auto __intrusive_from_this() const noexcept -> __intrusive_ptr; private: friend _Ty; void __inc_ref() noexcept; @@ -68,7 +68,7 @@ namespace stdexec { __value().~_Ty(); } - _Ty& __value() noexcept { + auto __value() noexcept -> _Ty& { return *reinterpret_cast<_Ty*>(__value_); } @@ -131,17 +131,17 @@ namespace stdexec { : __intrusive_ptr(__that ? __that->__intrusive_from_this() : __intrusive_ptr()) { } - __intrusive_ptr& operator=(__intrusive_ptr&& __that) noexcept { + auto operator=(__intrusive_ptr&& __that) noexcept -> __intrusive_ptr& { [[maybe_unused]] __intrusive_ptr __old{ std::exchange(__data_, std::exchange(__that.__data_, nullptr))}; return *this; } - __intrusive_ptr& operator=(const __intrusive_ptr& __that) noexcept { + auto operator=(const __intrusive_ptr& __that) noexcept -> __intrusive_ptr& { return operator=(__intrusive_ptr(__that)); } - __intrusive_ptr& operator=(__enable_intrusive_from_this<_Ty>* __that) noexcept { + auto operator=(__enable_intrusive_from_this<_Ty>* __that) noexcept -> __intrusive_ptr& { return operator=(__that ? __that->__intrusive_from_this() : __intrusive_ptr()); } @@ -157,15 +157,15 @@ namespace stdexec { std::swap(__data_, __that.__data_); } - _Ty* get() const noexcept { + auto get() const noexcept -> _Ty* { return &__data_->__value(); } - _Ty* operator->() const noexcept { + auto operator->() const noexcept -> _Ty* { return &__data_->__value(); } - _Ty& operator*() const noexcept { + auto operator*() const noexcept -> _Ty& { return __data_->__value(); } @@ -173,27 +173,28 @@ namespace stdexec { return __data_ != nullptr; } - bool operator!() const noexcept { + auto operator!() const noexcept -> bool { return __data_ == nullptr; } - bool operator==(const __intrusive_ptr&) const = default; + auto operator==(const __intrusive_ptr&) const -> bool = default; - bool operator==(std::nullptr_t) const noexcept { + auto operator==(std::nullptr_t) const noexcept -> bool { return __data_ == nullptr; } }; template - __intrusive_ptr<_Ty> __enable_intrusive_from_this<_Ty>::__intrusive_from_this() noexcept { + auto __enable_intrusive_from_this<_Ty>::__intrusive_from_this() noexcept + -> __intrusive_ptr<_Ty> { auto* __data = reinterpret_cast<__control_block<_Ty>*>(static_cast<_Ty*>(this)); __data->__inc_ref_(); return __intrusive_ptr<_Ty>{__data}; } template - __intrusive_ptr - __enable_intrusive_from_this<_Ty>::__intrusive_from_this() const noexcept { + auto __enable_intrusive_from_this<_Ty>::__intrusive_from_this() const noexcept + -> __intrusive_ptr { auto* __data = reinterpret_cast<__control_block<_Ty>*>(static_cast(this)); __data->__inc_ref_(); return __intrusive_ptr{__data}; @@ -215,7 +216,7 @@ namespace stdexec { struct __make_intrusive_t { template requires constructible_from<_Ty, _Us...> - __intrusive_ptr<_Ty> operator()(_Us&&... __us) const { + auto operator()(_Us&&... __us) const -> __intrusive_ptr<_Ty> { using _UncvTy = std::remove_cv_t<_Ty>; return __intrusive_ptr<_Ty>{::new __control_block<_UncvTy>{static_cast<_Us&&>(__us)...}}; } diff --git a/include/stdexec/__detail/__intrusive_queue.hpp b/include/stdexec/__detail/__intrusive_queue.hpp index c24db6221..88bc51eda 100644 --- a/include/stdexec/__detail/__intrusive_queue.hpp +++ b/include/stdexec/__detail/__intrusive_queue.hpp @@ -42,7 +42,7 @@ namespace stdexec { , __tail_(__tail) { } - __intrusive_queue& operator=(__intrusive_queue __other) noexcept { + auto operator=(__intrusive_queue __other) noexcept -> __intrusive_queue& { std::swap(__head_, __other.__head_); std::swap(__tail_, __other.__tail_); return *this; @@ -52,7 +52,7 @@ namespace stdexec { STDEXEC_ASSERT(empty()); } - static __intrusive_queue make_reversed(_Item* __list) noexcept { + static auto make_reversed(_Item* __list) noexcept -> __intrusive_queue { _Item* __new_head = nullptr; _Item* __new_tail = __list; while (__list != nullptr) { @@ -68,7 +68,7 @@ namespace stdexec { return __result; } - static __intrusive_queue make(_Item* __list) noexcept { + static auto make(_Item* __list) noexcept -> __intrusive_queue { __intrusive_queue __result{}; __result.__head_ = __list; __result.__tail_ = __list; @@ -82,7 +82,7 @@ namespace stdexec { } [[nodiscard]] - bool empty() const noexcept { + auto empty() const noexcept -> bool { return __head_ == nullptr; } @@ -92,7 +92,7 @@ namespace stdexec { } [[nodiscard]] - _Item* pop_front() noexcept { + auto pop_front() noexcept -> _Item* { STDEXEC_ASSERT(!empty()); _Item* __item = std::exchange(__head_, __head_->*_Next); // This should test if __head_ == nullptr, but due to a bug in @@ -165,20 +165,20 @@ namespace stdexec { } [[nodiscard]] - _Item* - operator*() const noexcept { + auto + operator*() const noexcept -> _Item* { STDEXEC_ASSERT(__item_ != nullptr); return __item_; } [[nodiscard]] - _Item** - operator->() const noexcept { + auto + operator->() const noexcept -> _Item** { STDEXEC_ASSERT(__item_ != nullptr); return &__item_; } - iterator& operator++() noexcept { + auto operator++() noexcept -> iterator& { __predecessor_ = __item_; if (__item_) { __item_ = __item_->*_Next; @@ -186,22 +186,22 @@ namespace stdexec { return *this; } - iterator operator++(int) noexcept { + auto operator++(int) noexcept -> iterator { iterator __result = *this; ++*this; return __result; } - friend bool operator==(const iterator&, const iterator&) noexcept = default; + friend auto operator==(const iterator&, const iterator&) noexcept -> bool = default; }; [[nodiscard]] - iterator begin() const noexcept { + auto begin() const noexcept -> iterator { return iterator(nullptr, __head_); } [[nodiscard]] - iterator end() const noexcept { + auto end() const noexcept -> iterator { return iterator(__tail_, nullptr); } @@ -232,11 +232,11 @@ namespace stdexec { } } - _Item* front() const noexcept { + auto front() const noexcept -> _Item* { return __head_; } - _Item* back() const noexcept { + auto back() const noexcept -> _Item* { return __tail_; } diff --git a/include/stdexec/__detail/__meta.hpp b/include/stdexec/__detail/__meta.hpp index f0da772d8..dde607e11 100644 --- a/include/stdexec/__detail/__meta.hpp +++ b/include/stdexec/__detail/__meta.hpp @@ -55,10 +55,10 @@ namespace stdexec { __move_only() = default; __move_only(__move_only&&) noexcept = default; - __move_only& operator=(__move_only&&) noexcept = default; + auto operator=(__move_only&&) noexcept -> __move_only& = default; __move_only(const __move_only&) = delete; - __move_only& operator=(const __move_only&) = delete; + auto operator=(const __move_only&) -> __move_only& = delete; }; template @@ -148,16 +148,16 @@ namespace stdexec { : __what_{__chars...} { } - static constexpr std::size_t __length() noexcept { + static constexpr auto __length() noexcept -> std::size_t { return _Len; } template - constexpr bool __equal(__mstring __other, __indices<_Is...>) const noexcept { + constexpr auto __equal(__mstring __other, __indices<_Is...>) const noexcept -> bool { return ((__what_[_Is] == __other.__what_[_Is]) && ...); } - constexpr bool operator==(__mstring __other) const noexcept { + constexpr auto operator==(__mstring __other) const noexcept -> bool { return __equal(__other, __make_indices<_Len>()); } @@ -202,14 +202,14 @@ namespace stdexec { // Use a standard user-defined string literal template template <__mstring _Str> [[deprecated("Use _mstr instead")]] - constexpr __mtypeof<_Str> - operator""__csz() noexcept { + constexpr auto + operator""__csz() noexcept -> __mtypeof<_Str> { return _Str; } // Use a standard user-defined string literal template template <__mstring _Str> - constexpr __mtypeof<_Str> operator""_mstr() noexcept { + constexpr auto operator""_mstr() noexcept -> __mtypeof<_Str> { return _Str; } #endif @@ -223,7 +223,7 @@ namespace stdexec { template struct _ERROR_ { - _ERROR_ operator,(__msuccess) const noexcept; + auto operator,(__msuccess) const noexcept -> _ERROR_; }; template <__mstring _What> @@ -781,7 +781,7 @@ namespace stdexec { return static_cast<_Fn&&>(__fn_)(); } - __t operator()() && noexcept(__nothrow_callable<_Fn>) { + auto operator()() && noexcept(__nothrow_callable<_Fn>) -> __t { return static_cast<_Fn&&>(__fn_)(); } }; @@ -792,7 +792,7 @@ namespace stdexec { // because of a bizarre nvc++ compiler bug: struct __cref_fn { template - const _Ty& operator()(const _Ty&); + auto operator()(const _Ty&) -> const _Ty&; }; template using __cref_t = decltype(__cref_fn{}(__declval<_Ty>())); @@ -830,7 +830,7 @@ namespace stdexec { decltype(stdexec::__mconvert_indices>); #else template - __types<__msize_t<_Indices>...> __mconvert_indices(std::index_sequence<_Indices...>*); + auto __mconvert_indices(std::index_sequence<_Indices...>*) -> __types<__msize_t<_Indices>...>; template using __mmake_index_sequence = decltype(stdexec::__mconvert_indices(static_cast*>(nullptr))); @@ -961,7 +961,7 @@ namespace stdexec { constexpr __placeholder(void*) noexcept { } - friend constexpr std::size_t __get_placeholder_offset(__placeholder) noexcept { + friend constexpr auto __get_placeholder_offset(__placeholder) noexcept -> std::size_t { return _Np; } }; @@ -1040,7 +1040,7 @@ namespace stdexec { template struct __mdispatch_ { template - _Ty operator()(_Ts&&...) const noexcept(noexcept(_Ty{})) { + auto operator()(_Ts&&...) const noexcept(noexcept(_Ty{})) -> _Ty { return _Ty{}; } }; @@ -1048,7 +1048,7 @@ namespace stdexec { template struct __mdispatch_<__placeholder<_Np>, _Offset> { template - decltype(auto) operator()(_Ts&&... __ts) const noexcept { + auto operator()(_Ts&&... __ts) const noexcept -> decltype(auto) { return stdexec::__nth_pack_element<_Np + _Offset>(static_cast<_Ts&&>(__ts)...); } }; @@ -1056,7 +1056,7 @@ namespace stdexec { template struct __mdispatch_<__placeholder<_Np>&, _Offset> { template - decltype(auto) operator()(_Ts&&... __ts) const noexcept { + auto operator()(_Ts&&... __ts) const noexcept -> decltype(auto) { return stdexec::__nth_pack_element<_Np + _Offset>(__ts...); } }; @@ -1064,7 +1064,7 @@ namespace stdexec { template struct __mdispatch_<__placeholder<_Np>&&, _Offset> { template - decltype(auto) operator()(_Ts&&... __ts) const noexcept { + auto operator()(_Ts&&... __ts) const noexcept -> decltype(auto) { return std::move(stdexec::__nth_pack_element<_Np + _Offset>(__ts...)); } }; @@ -1072,7 +1072,7 @@ namespace stdexec { template struct __mdispatch_&, _Offset> { template - decltype(auto) operator()(_Ts&&... __ts) const noexcept { + auto operator()(_Ts&&... __ts) const noexcept -> decltype(auto) { return std::as_const(stdexec::__nth_pack_element<_Np + _Offset>(__ts...)); } }; diff --git a/include/stdexec/__detail/__type_traits.hpp b/include/stdexec/__detail/__type_traits.hpp index e2302be07..a9ea8d7e9 100644 --- a/include/stdexec/__detail/__type_traits.hpp +++ b/include/stdexec/__detail/__type_traits.hpp @@ -22,7 +22,7 @@ namespace stdexec { ////////////////////////////////////////////////////////////////////////////////////////////////// // A very simple std::declval replacement that doesn't handle void template - _Tp&& __declval() noexcept; + auto __declval() noexcept -> _Tp&&; ////////////////////////////////////////////////////////////////////////////////////////////////// // __decay_t: An efficient implementation for std::decay @@ -176,7 +176,7 @@ namespace stdexec { namespace __tt { template - _Ty __remove_rvalue_reference_fn(_Ty&&); + auto __remove_rvalue_reference_fn(_Ty&&) -> _Ty; } // namespace __tt template diff --git a/include/stdexec/coroutine.hpp b/include/stdexec/coroutine.hpp index 0d8ba4d04..84b18504e 100644 --- a/include/stdexec/coroutine.hpp +++ b/include/stdexec/coroutine.hpp @@ -62,7 +62,7 @@ namespace stdexec { # endif template - decltype(auto) __get_awaiter(_Awaitable&& __awaitable, void*) { + auto __get_awaiter(_Awaitable&& __awaitable, void*) -> decltype(auto) { if constexpr (requires { static_cast<_Awaitable&&>(__awaitable).operator co_await(); }) { return static_cast<_Awaitable&&>(__awaitable).operator co_await(); } else if constexpr (requires { @@ -79,7 +79,7 @@ namespace stdexec { } template - decltype(auto) __get_awaiter(_Awaitable&& __awaitable, _Promise* __promise) + auto __get_awaiter(_Awaitable&& __awaitable, _Promise* __promise) -> decltype(auto) requires requires { __promise->await_transform(static_cast<_Awaitable&&>(__awaitable)); } { if constexpr ( @@ -110,7 +110,7 @@ namespace stdexec { }; template - _Tp& __as_lvalue(_Tp&&); + auto __as_lvalue(_Tp&&) -> _Tp&; template requires __awaitable<_Awaitable, _Promise> diff --git a/include/stdexec/execution.hpp b/include/stdexec/execution.hpp index 988ff2d4c..037997061 100644 --- a/include/stdexec/execution.hpp +++ b/include/stdexec/execution.hpp @@ -271,7 +271,7 @@ namespace stdexec { template requires nothrow_tag_invocable<_Tag, _Receiver, _Args...> - __msuccess __try_completion(_Tag (*)(_Args...)); + auto __try_completion(_Tag (*)(_Args...)) -> __msuccess; template auto __try_completions(completion_signatures<_Sigs...>*) -> decltype(( @@ -333,7 +333,8 @@ namespace stdexec { // Some utilities for debugging senders namespace __debug { struct __is_debug_env_t { - friend constexpr bool tag_invoke(forwarding_query_t, const __is_debug_env_t&) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, const __is_debug_env_t&) noexcept + -> bool { return true; } template @@ -401,8 +402,8 @@ namespace stdexec { template _Tag> STDEXEC_ATTRIBUTE((host, device)) - friend __debug_env_t<_Env> - tag_invoke(_Tag, __debug_receiver) noexcept { + friend auto + tag_invoke(_Tag, __debug_receiver) noexcept -> __debug_env_t<_Env> { STDEXEC_TERMINATE(); } }; @@ -612,8 +613,8 @@ namespace stdexec { // the sender with the requested domain. template requires same_as<__early_domain_of_t<_Sender>, dependent_domain> - /*constexpr*/ decltype(auto) - operator()(_Domain __dom, _Sender&& __sndr, const _Env& __env) const { + /*constexpr*/ auto operator()(_Domain __dom, _Sender&& __sndr, const _Env& __env) const + -> decltype(auto) { static_assert(__none_of<_Domain, dependent_domain>); return __transform_sender()( __dom, dependent_domain().transform_sender(static_cast<_Sender&&>(__sndr), __env), __env); @@ -639,7 +640,8 @@ namespace stdexec { template requires same_as<__early_domain_of_t<_Sender>, dependent_domain> - decltype(auto) dependent_domain::transform_sender(_Sender&& __sndr, const _Env& __env) const { + auto dependent_domain::transform_sender(_Sender&& __sndr, const _Env& __env) const + -> decltype(auto) { // apply any algorithm-specific transformation to the environment const auto& __env2 = transform_env(*this, static_cast<_Sender&&>(__sndr), __env); @@ -1097,7 +1099,7 @@ namespace stdexec { return tag_invoke(schedule_t{}, static_cast<_Scheduler&&>(__sched)); } - friend constexpr bool tag_invoke(forwarding_query_t, schedule_t) { + friend constexpr auto tag_invoke(forwarding_query_t, schedule_t) -> bool { return false; } }; @@ -1182,12 +1184,12 @@ namespace stdexec { // __connect_awaitable_ namespace __connect_awaitable_ { struct __promise_base { - __coro::suspend_always initial_suspend() noexcept { + auto initial_suspend() noexcept -> __coro::suspend_always { return {}; } [[noreturn]] - __coro::suspend_always final_suspend() noexcept { + auto final_suspend() noexcept -> __coro::suspend_always { std::terminate(); } @@ -1256,7 +1258,7 @@ namespace stdexec { : __rcvr_(__rcvr) { } - __coro::coroutine_handle<> unhandled_stopped() noexcept { + auto unhandled_stopped() noexcept -> __coro::coroutine_handle<> { set_stopped(static_cast<_Receiver&&>(__rcvr_)); // Returning noop_coroutine here causes the __connect_awaitable // coroutine to never resume past the point where it co_await's @@ -1264,13 +1266,13 @@ namespace stdexec { return __coro::noop_coroutine(); } - stdexec::__t<__operation<_ReceiverId>> get_return_object() noexcept { + auto get_return_object() noexcept -> stdexec::__t<__operation<_ReceiverId>> { return stdexec::__t<__operation<_ReceiverId>>{ __coro::coroutine_handle<__t>::from_promise(*this)}; } template - _Awaitable&& await_transform(_Awaitable&& __awaitable) noexcept { + auto await_transform(_Awaitable&& __awaitable) noexcept -> _Awaitable&& { return static_cast<_Awaitable&&>(__awaitable); } @@ -1308,7 +1310,7 @@ namespace stdexec { struct __awaiter { decltype(__fn) __fn_; - static constexpr bool await_ready() noexcept { + static constexpr auto await_ready() noexcept -> bool { return false; } @@ -1329,8 +1331,8 @@ namespace stdexec { # if STDEXEC_GCC() && (__GNUC__ > 11) __attribute__((__used__)) # endif - static __operation_t<_Receiver> - __co_impl(_Awaitable __awaitable, _Receiver __rcvr) { + static auto + __co_impl(_Awaitable __awaitable, _Receiver __rcvr) -> __operation_t<_Receiver> { using __result_t = __await_result_t<_Awaitable, __promise_t<_Receiver>>; std::exception_ptr __eptr; try { @@ -1362,7 +1364,8 @@ namespace stdexec { public: template > _Awaitable> requires receiver_of<_Receiver, __completions_t<_Receiver, _Awaitable>> - __operation_t<_Receiver> operator()(_Awaitable&& __awaitable, _Receiver __rcvr) const { + auto operator()(_Awaitable&& __awaitable, _Receiver __rcvr) const + -> __operation_t<_Receiver> { return __co_impl(static_cast<_Awaitable&&>(__awaitable), static_cast<_Receiver&&>(__rcvr)); } }; @@ -1404,7 +1407,7 @@ namespace stdexec { struct connect_t { template - static constexpr bool __check_signatures() { + static constexpr auto __check_signatures() -> bool { if constexpr (sender_in<_Sender, _Env>) { // Instantiate __debug_sender via completion_signatures_of_t // to check that the actual completions match the expected @@ -1482,7 +1485,7 @@ namespace stdexec { } } - friend constexpr bool tag_invoke(forwarding_query_t, connect_t) noexcept { + friend constexpr auto tag_invoke(forwarding_query_t, connect_t) noexcept -> bool { return false; } }; @@ -1503,7 +1506,7 @@ namespace stdexec { }; template - _Tag __tag_of_sig_(_Tag (*)(_Args...)); + auto __tag_of_sig_(_Tag (*)(_Args...)) -> _Tag; template using __tag_of_sig_t = decltype(stdexec::__tag_of_sig_(static_cast<_Sig*>(nullptr))); @@ -1578,7 +1581,7 @@ namespace stdexec { } // Forward get_env query to the coroutine promise - friend env_of_t<_Promise&> tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> env_of_t<_Promise&> { auto __continuation = __coro::coroutine_handle<_Promise>::from_address( __self.__continuation_.address()); return get_env(__continuation.promise()); @@ -1610,11 +1613,12 @@ namespace stdexec { template struct __sender_awaitable_base { - bool await_ready() const noexcept { + [[nodiscard]] + auto await_ready() const noexcept -> bool { return false; } - _Value await_resume() { + auto await_resume() -> _Value { switch (__result_.index()) { case 0: // receiver contract not satisfied STDEXEC_ASSERT(!"_Should never get here"); @@ -1672,12 +1676,12 @@ namespace stdexec { }; struct __unspecified { - __unspecified get_return_object() noexcept; - __unspecified initial_suspend() noexcept; - __unspecified final_suspend() noexcept; + auto get_return_object() noexcept -> __unspecified; + auto initial_suspend() noexcept -> __unspecified; + auto final_suspend() noexcept -> __unspecified; void unhandled_exception() noexcept; void return_void() noexcept; - __coro::coroutine_handle<> unhandled_stopped() noexcept; + auto unhandled_stopped() noexcept -> __coro::coroutine_handle<>; }; struct as_awaitable_t { @@ -1752,11 +1756,13 @@ namespace stdexec { // is called. } - __coro::coroutine_handle<> handle() const noexcept { + [[nodiscard]] + auto handle() const noexcept -> __coro::coroutine_handle<> { return __coro_; } - __coro::coroutine_handle<> unhandled_stopped() const noexcept { + [[nodiscard]] + auto unhandled_stopped() const noexcept -> __coro::coroutine_handle<> { return __stopped_callback_(__coro_.address()); } @@ -1777,11 +1783,12 @@ namespace stdexec { : __continuation_{__coro} { } - __coro::coroutine_handle<_Promise> handle() const noexcept { + auto handle() const noexcept -> __coro::coroutine_handle<_Promise> { return __coro::coroutine_handle<_Promise>::from_address(__continuation_.handle().address()); } - __coro::coroutine_handle<> unhandled_stopped() const noexcept { + [[nodiscard]] + auto unhandled_stopped() const noexcept -> __coro::coroutine_handle<> { return __continuation_.unhandled_stopped(); } @@ -1800,11 +1807,12 @@ namespace stdexec { __continuation_ = __continuation; } - __continuation_handle<> continuation() const noexcept { + [[nodiscard]] + auto continuation() const noexcept -> __continuation_handle<> { return __continuation_; } - __coro::coroutine_handle<> unhandled_stopped() noexcept { + auto unhandled_stopped() noexcept -> __coro::coroutine_handle<> { return __continuation_.unhandled_stopped(); } @@ -1942,12 +1950,12 @@ namespace stdexec { return __make_sexpr<_Tag>(); } - friend forward_progress_guarantee - tag_invoke(get_forward_progress_guarantee_t, __scheduler) noexcept { + friend auto tag_invoke(get_forward_progress_guarantee_t, __scheduler) noexcept + -> forward_progress_guarantee { return forward_progress_guarantee::weakly_parallel; } - bool operator==(const __scheduler&) const noexcept = default; + auto operator==(const __scheduler&) const noexcept -> bool = default; }; } // namespace __inln @@ -1997,7 +2005,7 @@ namespace stdexec { friend void tag_invoke(_Tag, __t&&) noexcept { } - friend const _Env& tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> const _Env& { // BUGBUG NOT TO SPEC return __self.__env_; } @@ -2148,7 +2156,7 @@ namespace stdexec { friend void tag_invoke(_Tag, __as_receiver&&) noexcept { } - friend empty_env tag_invoke(get_env_t, const __as_receiver&) noexcept { + friend auto tag_invoke(get_env_t, const __as_receiver&) noexcept -> empty_env { return {}; } }; @@ -2264,12 +2272,10 @@ namespace stdexec { template requires __callable STDEXEC_ATTRIBUTE((host, device)) - __call_result_t< - const _Fun&, - _Sender, - const _As&...> + auto operator()(_Sender&& __sndr) const & // - noexcept(__nothrow_callable) { + noexcept(__nothrow_callable) + -> __call_result_t { return __apply( [&__sndr, this](const _As&... __as) -> __call_result_t { @@ -2290,8 +2296,8 @@ namespace stdexec { // accessible from derived. template STDEXEC_ATTRIBUTE((host, device)) - __copy_cvref_t<_Up&&, _Tp> - __c_cast(_Up&& u) noexcept + auto + __c_cast(_Up&& u) noexcept -> __copy_cvref_t<_Up&&, _Tp> requires __decays_to<_Tp, _Tp> { static_assert(std::is_reference_v<__copy_cvref_t<_Up&&, _Tp>>); @@ -2311,7 +2317,7 @@ namespace stdexec { void tag_invoke(_Tag, __receiver, std::exception_ptr) noexcept; template _Tag> void tag_invoke(_Tag, __receiver) noexcept; - empty_env tag_invoke(get_env_t, __receiver) noexcept; + auto tag_invoke(get_env_t, __receiver) noexcept -> empty_env; } // namespace __no using __not_a_receiver = __no::__receiver; @@ -2406,8 +2412,8 @@ namespace stdexec { template STDEXEC_ATTRIBUTE((host, device)) - static __base_t<_Dp> - __get_base(_Dp&& __self) noexcept { + static auto + __get_base(_Dp&& __self) noexcept -> __base_t<_Dp> { if constexpr (__has_base) { return __c_cast(static_cast<_Dp&&>(__self)).base(); } else { @@ -2603,7 +2609,7 @@ namespace stdexec { //////////////////////////////////////////////////////////////////////////////////////////////// struct then_t { template - __well_formed_sender auto operator()(_Sender&& __sndr, _Fun __fun) const { + auto operator()(_Sender&& __sndr, _Fun __fun) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -2682,7 +2688,7 @@ namespace stdexec { //////////////////////////////////////////////////////////////////////////////////////////////// struct upon_error_t { template - __well_formed_sender auto operator()(_Sender&& __sndr, _Fun __fun) const { + auto operator()(_Sender&& __sndr, _Fun __fun) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -2759,7 +2765,7 @@ namespace stdexec { struct upon_stopped_t { template requires __callable<_Fun> - __well_formed_sender auto operator()(_Sender&& __sndr, _Fun __fun) const { + auto operator()(_Sender&& __sndr, _Fun __fun) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -2858,8 +2864,9 @@ namespace stdexec { struct bulk_t { template STDEXEC_ATTRIBUTE((host, device)) - __well_formed_sender auto - operator()(_Sender&& __sndr, _Shape __shape, _Fun __fun) const { + auto + operator()(_Sender&& __sndr, _Shape __shape, _Fun __fun) const -> __well_formed_sender + auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -3038,7 +3045,7 @@ namespace stdexec { // from start: template static void __action(__local_state_base* __self, __action_kind __kind) noexcept { - __local_state* const __op = static_cast<__local_state*>(__self); + auto* const __op = static_cast<__local_state*>(__self); if (__kind == __action_kind::__notify) { __op->__on_stop_.reset(); @@ -3092,7 +3099,7 @@ namespace stdexec { __state.__notify(); } - friend const __env_t<_Env>& tag_invoke(get_env_t, const __t& __self) noexcept { + friend auto tag_invoke(get_env_t, const __t& __self) noexcept -> const __env_t<_Env>& { return __self.__shared_state_->__env_; } @@ -3146,7 +3153,7 @@ namespace stdexec { void __notify() noexcept { void* const __completion_state = static_cast(this); void* const __old = __head_.exchange(__completion_state, std::memory_order_acq_rel); - __local_state_base* __state = static_cast<__local_state_base*>(__old); + auto* __state = static_cast<__local_state_base*>(__old); while (__state != nullptr) { __local_state_base* __next = __state->__next_; @@ -3288,7 +3295,7 @@ namespace stdexec { struct split_t { template requires sender_in<_Sender, _Env> && __decay_copyable> - __well_formed_sender auto operator()(_Sender&& __sndr, _Env&& __env = {}) const { + auto operator()(_Sender&& __sndr, _Env&& __env = {}) const -> __well_formed_sender auto { auto __domain = __get_late_domain(__sndr, __env); return stdexec::transform_sender( __domain, @@ -3351,7 +3358,7 @@ namespace stdexec { } __data(__data&&) noexcept = default; - __data& operator=(__data&&) noexcept = default; + auto operator=(__data&&) noexcept -> __data& = default; ~__data() { if (__shared_state != nullptr) { @@ -3370,8 +3377,8 @@ namespace stdexec { template requires sender_in<_Sender, _Env> && __decay_copyable> [[nodiscard]] - __well_formed_sender auto - operator()(_Sender&& __sndr, _Env&& __env = {}) const { + auto + operator()(_Sender&& __sndr, _Env&& __env = {}) const -> __well_formed_sender auto { if constexpr (sender_expr_for<_Sender, __ensure_started_t>) { return static_cast<_Sender&&>(__sndr); } else { @@ -3441,11 +3448,11 @@ namespace stdexec { _Operation* __op_state_; - _Receiver&& base() && noexcept { + auto base() && noexcept -> _Receiver&& { return static_cast<_Receiver&&>(__op_state_->*_ReceiverPtr); } - __env_t get_env() const noexcept { + auto get_env() const noexcept -> __env_t { return __env::__join( _EnvFns(__op_state_)..., stdexec::get_env(__op_state_->*_ReceiverPtr)); } @@ -3691,7 +3698,7 @@ namespace stdexec { __transform<__uncurry<__op_state_for<_Receiver, _Fun, _Set, _Sched>>, __nullable_variant_t>, _Tuples...>; - decltype(auto) __get_result_receiver(_Receiver&& __rcvr) { + auto __get_result_receiver(_Receiver&& __rcvr) -> decltype(auto) { if constexpr (__unknown_context<_Sched>) { return static_cast<_Receiver&&>(__rcvr); } else { @@ -3711,7 +3718,7 @@ namespace stdexec { using __t = _Set; template - __well_formed_sender auto operator()(_Sender&& __sndr, _Fun __fun) const { + auto operator()(_Sender&& __sndr, _Fun __fun) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -3736,14 +3743,14 @@ namespace stdexec { tag_invoke_t(__let_t, _Sender, _Function)>; template > _Sender, class _Env> - static decltype(auto) transform_env(_Sender&& __sndr, const _Env& __env) { + static auto transform_env(_Sender&& __sndr, const _Env& __env) -> decltype(auto) { return __sexpr_apply( static_cast<_Sender&&>(__sndr), __mk_transform_env_fn<__let_t<_Set>>(__env)); } template > _Sender, class _Env> requires same_as<__early_domain_of_t<_Sender>, dependent_domain> - static decltype(auto) transform_sender(_Sender&& __sndr, const _Env& __env) { + static auto transform_sender(_Sender&& __sndr, const _Env& __env) -> decltype(auto) { return __sexpr_apply( static_cast<_Sender&&>(__sndr), __mk_transform_sender_fn<__let_t<_Set>>(__env)); } @@ -4000,7 +4007,7 @@ namespace stdexec { struct __scheduler { using __t = __scheduler; using __id = __scheduler; - bool operator==(const __scheduler&) const noexcept = default; + auto operator==(const __scheduler&) const noexcept -> bool = default; private: struct __schedule_task { @@ -4017,13 +4024,13 @@ namespace stdexec { using __operation = stdexec::__t<__operation>>; template - friend __operation<_Receiver> - tag_invoke(connect_t, const __schedule_task& __self, _Receiver __rcvr) { + friend auto tag_invoke(connect_t, const __schedule_task& __self, _Receiver __rcvr) + -> __operation<_Receiver> { return __self.__connect_(static_cast<_Receiver&&>(__rcvr)); } template - __operation<_Receiver> __connect_(_Receiver&& __rcvr) const { + auto __connect_(_Receiver&& __rcvr) const -> __operation<_Receiver> { return {&__loop_->__head_, __loop_, static_cast<_Receiver&&>(__rcvr)}; } @@ -4031,13 +4038,13 @@ namespace stdexec { run_loop* __loop_; template - friend __scheduler - tag_invoke(get_completion_scheduler_t<_CPO>, const __env& __self) noexcept { + friend auto tag_invoke(get_completion_scheduler_t<_CPO>, const __env& __self) noexcept + -> __scheduler { return __self.__loop_->get_scheduler(); } }; - friend __env tag_invoke(get_env_t, const __schedule_task& __self) noexcept { + friend auto tag_invoke(get_env_t, const __schedule_task& __self) noexcept -> __env { return __env{__self.__loop_}; } @@ -4054,28 +4061,29 @@ namespace stdexec { : __loop_(__loop) { } - friend __schedule_task tag_invoke(schedule_t, const __scheduler& __self) noexcept { + friend auto tag_invoke(schedule_t, const __scheduler& __self) noexcept -> __schedule_task { return __self.__schedule(); } - friend stdexec::forward_progress_guarantee - tag_invoke(get_forward_progress_guarantee_t, const __scheduler&) noexcept { + friend auto tag_invoke(get_forward_progress_guarantee_t, const __scheduler&) noexcept + -> stdexec::forward_progress_guarantee { return stdexec::forward_progress_guarantee::parallel; } // BUGBUG NOT TO SPEC - friend bool tag_invoke(execute_may_block_caller_t, const __scheduler&) noexcept { + friend auto tag_invoke(execute_may_block_caller_t, const __scheduler&) noexcept -> bool { return false; } - __schedule_task __schedule() const noexcept { + [[nodiscard]] + auto __schedule() const noexcept -> __schedule_task { return __schedule_task{__loop_}; } run_loop* __loop_; }; - __scheduler get_scheduler() noexcept { + auto get_scheduler() noexcept -> __scheduler { return __scheduler{this}; } @@ -4085,7 +4093,7 @@ namespace stdexec { private: void __push_back_(__task* __task); - __task* __pop_front_(); + auto __pop_front_() -> __task*; std::mutex __mutex_; std::condition_variable __cv_; @@ -4121,7 +4129,7 @@ namespace stdexec { __cv_.notify_one(); } - inline __task* run_loop::__pop_front_() { + inline auto run_loop::__pop_front_() -> __task* { std::unique_lock __lock{__mutex_}; __cv_.wait(__lock, [this] { return __head_.__next_ != &__head_ || __stop_; }); if (__head_.__tail_ == __head_.__next_) @@ -4229,11 +4237,11 @@ namespace stdexec { : __state_{__state} { } - _Receiver&& base() && noexcept { + auto base() && noexcept -> _Receiver&& { return std::move(__state_->__receiver()); } - const _Receiver& base() const & noexcept { + auto base() const & noexcept -> const _Receiver& { return __state_->__receiver(); } @@ -4273,7 +4281,7 @@ namespace stdexec { struct schedule_from_t { template - __well_formed_sender auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const { + auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const -> __well_formed_sender auto { using _Env = __t<__environ<__id<__decay_t<_Scheduler>>>>; auto __env = _Env{{static_cast<_Scheduler&&>(__sched)}}; auto __domain = query_or(get_domain, __sched, default_domain()); @@ -4362,7 +4370,7 @@ namespace stdexec { struct transfer_t { template - __well_formed_sender auto operator()(_Sender&& __sndr, _Scheduler&& __sched) const { + auto operator()(_Sender&& __sndr, _Scheduler&& __sched) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); using _Env = __t<__environ<__id<__decay_t<_Scheduler>>>>; return stdexec::transform_sender( @@ -4450,7 +4458,8 @@ namespace stdexec { __types<__apply_t(decltype(__transfer_just_tag_invoke()), _Data)>; template - __well_formed_sender auto operator()(_Scheduler&& __sched, _Values&&... __vals) const { + auto operator()(_Scheduler&& __sched, _Values&&... __vals) const -> __well_formed_sender + auto { auto __domain = query_or(get_domain, __sched, default_domain()); return stdexec::transform_sender( __domain, @@ -4559,7 +4568,7 @@ namespace stdexec { struct __always { _Ty __val_; - _Ty operator()() noexcept { + auto operator()() noexcept -> _Ty { return static_cast<_Ty&&>(__val_); } }; @@ -4577,7 +4586,7 @@ namespace stdexec { using __legacy_customizations_t = __types; template - __well_formed_sender auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const { + auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const -> __well_formed_sender auto { auto __domain = query_or(get_domain, __sched, default_domain()); return stdexec::transform_sender( __domain, @@ -4636,7 +4645,7 @@ namespace stdexec { struct into_variant_t { template - __well_formed_sender auto operator()(_Sender&& __sndr) const { + auto operator()(_Sender&& __sndr) const -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, __make_sexpr(__(), std::forward<_Sender>(__sndr))); @@ -4791,7 +4800,7 @@ namespace stdexec { struct __tie_fn { template - std::tuple<_Ty&...> operator()(_Ty&... __vals) noexcept { + auto operator()(_Ty&... __vals) noexcept -> std::tuple<_Ty&...> { return std::tuple<_Ty&...>{__vals...}; } }; @@ -4923,7 +4932,7 @@ namespace stdexec { template requires __domain::__has_common_domain<_Senders...> - __well_formed_sender auto operator()(_Senders&&... __sndrs) const { + auto operator()(_Senders&&... __sndrs) const -> __well_formed_sender auto { auto __domain = __domain::__common_domain_t<_Senders...>(); return stdexec::transform_sender( __domain, __make_sexpr(__(), static_cast<_Senders&&>(__sndrs)...)); @@ -5061,7 +5070,7 @@ namespace stdexec { template requires __domain::__has_common_domain<_Senders...> - __well_formed_sender auto operator()(_Senders&&... __sndrs) const { + auto operator()(_Senders&&... __sndrs) const -> __well_formed_sender auto { auto __domain = __domain::__common_domain_t<_Senders...>(); return stdexec::transform_sender( __domain, @@ -5104,7 +5113,8 @@ namespace stdexec { template requires __domain::__has_common_domain<_Senders...> - __well_formed_sender auto operator()(_Scheduler&& __sched, _Senders&&... __sndrs) const { + auto operator()(_Scheduler&& __sched, _Senders&&... __sndrs) const -> __well_formed_sender + auto { using _Env = __t<__schedule_from::__environ<__id<__decay_t<_Scheduler>>>>; auto __domain = query_or(get_domain, __sched, default_domain()); return stdexec::transform_sender( @@ -5146,7 +5156,8 @@ namespace stdexec { template requires __domain::__has_common_domain<_Senders...> - __well_formed_sender auto operator()(_Scheduler&& __sched, _Senders&&... __sndrs) const { + auto operator()(_Scheduler&& __sched, _Senders&&... __sndrs) const -> __well_formed_sender + auto { using _Env = __t<__schedule_from::__environ<__id<__decay_t<_Scheduler>>>>; auto __domain = query_or(get_domain, __sched, default_domain()); return stdexec::transform_sender( @@ -5394,7 +5405,7 @@ namespace stdexec { struct on_t : __no_scheduler_in_environment { template - __well_formed_sender auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const { + auto operator()(_Scheduler&& __sched, _Sender&& __sndr) const -> __well_formed_sender auto { // BUGBUG __get_early_domain, or get_domain(__sched), or ...? auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( @@ -5446,7 +5457,7 @@ namespace stdexec { struct __with_sched { _Scheduler __sched_; - friend _Scheduler tag_invoke(get_scheduler_t, const __with_sched& __self) noexcept { + friend auto tag_invoke(get_scheduler_t, const __with_sched& __self) noexcept -> _Scheduler { return __self.__sched_; } @@ -5460,8 +5471,8 @@ namespace stdexec { struct continue_on_t : __no_scheduler_in_environment { template _Closure> - __well_formed_sender auto - operator()(_Sender&& __sndr, _Scheduler&& __sched, _Closure&& __clsur) const { + auto operator()(_Sender&& __sndr, _Scheduler&& __sched, _Closure&& __clsur) const + -> __well_formed_sender auto { auto __domain = __get_early_domain(__sndr); return stdexec::transform_sender( __domain, @@ -5603,7 +5614,7 @@ namespace stdexec { __rcvr.__loop_->finish(); } - friend __env tag_invoke(get_env_t, const __t& __rcvr) noexcept { + friend auto tag_invoke(get_env_t, const __t& __rcvr) noexcept -> __env { return __env(*__rcvr.__loop_); } }; diff --git a/include/stdexec/functional.hpp b/include/stdexec/functional.hpp index a3d0cd42a..656c34c0c 100644 --- a/include/stdexec/functional.hpp +++ b/include/stdexec/functional.hpp @@ -185,7 +185,7 @@ namespace stdexec { } }; - __funobj __invoke_selector(__ignore, __ignore) noexcept; + auto __invoke_selector(__ignore, __ignore) noexcept -> __funobj; template auto __invoke_selector(_Mbr _Class::*, const _Ty&) noexcept { diff --git a/include/stdexec/stop_token.hpp b/include/stdexec/stop_token.hpp index d077eb85d..9bf47cffe 100644 --- a/include/stdexec/stop_token.hpp +++ b/include/stdexec/stop_token.hpp @@ -104,15 +104,15 @@ namespace stdexec { template using callback_type = __callback_type; - static constexpr bool stop_requested() noexcept { + static constexpr auto stop_requested() noexcept -> bool { return false; } - static constexpr bool stop_possible() noexcept { + static constexpr auto stop_possible() noexcept -> bool { return false; } - bool operator==(const never_stop_token&) const noexcept = default; + auto operator==(const never_stop_token&) const noexcept -> bool = default; }; template @@ -125,11 +125,11 @@ namespace stdexec { ~in_place_stop_source(); in_place_stop_source(in_place_stop_source&&) = delete; - in_place_stop_token get_token() const noexcept; + auto get_token() const noexcept -> in_place_stop_token; - bool request_stop() noexcept; + auto request_stop() noexcept -> bool; - bool stop_requested() const noexcept { + auto stop_requested() const noexcept -> bool { return (__state_.load(std::memory_order_acquire) & __stop_requested_flag_) != 0; } @@ -139,12 +139,12 @@ namespace stdexec { template friend class in_place_stop_callback; - uint8_t __lock_() const noexcept; + auto __lock_() const noexcept -> uint8_t; void __unlock_(uint8_t) const noexcept; - bool __try_lock_unless_stop_requested_(bool) const noexcept; + auto __try_lock_unless_stop_requested_(bool) const noexcept -> bool; - bool __try_add_callback_(__stok::__in_place_stop_callback_base*) const noexcept; + auto __try_add_callback_(__stok::__in_place_stop_callback_base*) const noexcept -> bool; void __remove_callback_(__stok::__in_place_stop_callback_base*) const noexcept; @@ -172,18 +172,20 @@ namespace stdexec { : __source_(std::exchange(__other.__source_, {})) { } - in_place_stop_token& operator=(const in_place_stop_token& __other) noexcept = default; + auto operator=(const in_place_stop_token& __other) noexcept -> in_place_stop_token& = default; - in_place_stop_token& operator=(in_place_stop_token&& __other) noexcept { + auto operator=(in_place_stop_token&& __other) noexcept -> in_place_stop_token& { __source_ = std::exchange(__other.__source_, nullptr); return *this; } - bool stop_requested() const noexcept { + [[nodiscard]] + auto stop_requested() const noexcept -> bool { return __source_ != nullptr && __source_->stop_requested(); } - bool stop_possible() const noexcept { + [[nodiscard]] + auto stop_possible() const noexcept -> bool { return __source_ != nullptr; } @@ -191,7 +193,7 @@ namespace stdexec { std::swap(__source_, __other.__source_); } - bool operator==(const in_place_stop_token&) const noexcept = default; + auto operator==(const in_place_stop_token&) const noexcept -> bool = default; private: friend in_place_stop_source; @@ -205,7 +207,7 @@ namespace stdexec { const in_place_stop_source* __source_; }; - inline in_place_stop_token in_place_stop_source::get_token() const noexcept { + inline auto in_place_stop_source::get_token() const noexcept -> in_place_stop_token { return in_place_stop_token{this}; } @@ -258,7 +260,7 @@ namespace stdexec { STDEXEC_ASSERT(__callbacks_ == nullptr); } - inline bool in_place_stop_source::request_stop() noexcept { + inline auto in_place_stop_source::request_stop() noexcept -> bool { if (!__try_lock_unless_stop_requested_(true)) return true; @@ -291,7 +293,7 @@ namespace stdexec { return false; } - inline uint8_t in_place_stop_source::__lock_() const noexcept { + inline auto in_place_stop_source::__lock_() const noexcept -> uint8_t { __stok::__spin_wait __spin; auto __old_state = __state_.load(std::memory_order_relaxed); do { @@ -312,8 +314,8 @@ namespace stdexec { (void) __state_.store(__old_state, std::memory_order_release); } - inline bool in_place_stop_source::__try_lock_unless_stop_requested_( - bool __set_stop_requested) const noexcept { + inline auto in_place_stop_source::__try_lock_unless_stop_requested_( + bool __set_stop_requested) const noexcept -> bool { __stok::__spin_wait __spin; auto __old_state = __state_.load(std::memory_order_relaxed); do { @@ -338,8 +340,8 @@ namespace stdexec { return true; } - inline bool in_place_stop_source::__try_add_callback_( - __stok::__in_place_stop_callback_base* __callbk) const noexcept { + inline auto in_place_stop_source::__try_add_callback_( + __stok::__in_place_stop_callback_base* __callbk) const noexcept -> bool { if (!__try_lock_unless_stop_requested_(false)) { return false; } diff --git a/include/tbbexec/tbb_thread_pool.hpp b/include/tbbexec/tbb_thread_pool.hpp index b91d73ad1..d541cc84e 100644 --- a/include/tbbexec/tbb_thread_pool.hpp +++ b/include/tbbexec/tbb_thread_pool.hpp @@ -48,7 +48,7 @@ namespace tbbexec { struct scheduler { using __t = scheduler; using __id = scheduler; - bool operator==(const scheduler&) const = default; + auto operator==(const scheduler&) const -> bool = default; private: template @@ -64,25 +64,25 @@ namespace tbbexec { private: template - stdexec::__t>> - make_operation_(Receiver rcvr) const { + auto make_operation_(Receiver rcvr) const + -> stdexec::__t>> { return stdexec::__t>>{ this->pool_, static_cast(rcvr)}; } template - friend stdexec::__t>> - tag_invoke(stdexec::connect_t, sender sndr, Receiver rcvr) { + friend auto tag_invoke(stdexec::connect_t, sender sndr, Receiver rcvr) + -> stdexec::__t>> { return sndr.make_operation_(std::move(rcvr)); } template - friend typename DerivedPoolType::scheduler - tag_invoke(stdexec::get_completion_scheduler_t, sender sndr) noexcept { + friend auto tag_invoke(stdexec::get_completion_scheduler_t, sender sndr) noexcept -> + typename DerivedPoolType::scheduler { return sndr.pool_.get_scheduler(); } - friend const sender& tag_invoke(stdexec::get_env_t, const sender& sndr) noexcept { + friend auto tag_invoke(stdexec::get_env_t, const sender& sndr) noexcept -> const sender& { return sndr; } @@ -131,8 +131,8 @@ namespace tbbexec { // even_share( 11, 1, 3); // -> [4, 8) -> 4 items // even_share( 11, 2, 3); // -> [8, 11) -> 3 items // ``` - static std::pair - even_share(Shape n, std::uint32_t rank, std::uint32_t size) noexcept { + static auto even_share(Shape n, std::uint32_t rank, std::uint32_t size) noexcept + -> std::pair { const auto avg_per_thread = n / size; const auto n_big_share = avg_per_thread + 1; const auto big_shares = n % size; @@ -145,7 +145,8 @@ namespace tbbexec { return std::make_pair(begin, end); } - std::uint32_t num_agents_required() const { + [[nodiscard]] + auto num_agents_required() const -> std::uint32_t { // With work stealing, is std::min necessary, or can we feel free to ask for more agents (tasks) // than we can actually deal with at one time? return std::min(shape_, static_cast(pool_.available_parallelism())); @@ -358,15 +359,14 @@ namespace tbbexec { template Self, stdexec::receiver Receiver> requires stdexec:: receiver_of>> - friend bulk_op_state_t - tag_invoke(stdexec::connect_t, Self&& self, Receiver rcvr) noexcept( + friend auto tag_invoke(stdexec::connect_t, Self&& self, Receiver rcvr) noexcept( stdexec::__nothrow_constructible_from< bulk_op_state_t, DerivedPoolType&, Shape, Fun, Sender, - Receiver>) { + Receiver>) -> bulk_op_state_t { return bulk_op_state_t{ self.pool_, self.shape_, @@ -394,17 +394,17 @@ namespace tbbexec { } template Tag> - friend const __t& tag_invoke(Tag tag, const __t& self) noexcept { + friend auto tag_invoke(Tag tag, const __t& self) noexcept -> const __t& { return self; } }; }; - sender make_sender() const { + auto make_sender() const -> sender { return sender{*pool_}; } - friend sender tag_invoke(stdexec::schedule_t, const scheduler& sch) noexcept { + friend auto tag_invoke(stdexec::schedule_t, const scheduler& sch) noexcept -> sender { return sch.make_sender(); } @@ -413,22 +413,22 @@ namespace tbbexec { stdexec::__t>, Shape, Fun>>; template - friend bulk_sender_t tag_invoke( - stdexec::bulk_t, - const scheduler& sch, - S&& sndr, - Shape shape, - Fun fun) noexcept { + friend auto + tag_invoke(stdexec::bulk_t, const scheduler& sch, S&& sndr, Shape shape, Fun fun) noexcept + -> bulk_sender_t { return bulk_sender_t{ *sch.pool_, static_cast(sndr), shape, static_cast(fun)}; } - constexpr stdexec::forward_progress_guarantee forward_progress_guarantee() const noexcept { + [[nodiscard]] + constexpr auto forward_progress_guarantee() const noexcept + -> stdexec::forward_progress_guarantee { return pool_->forward_progress_guarantee(); } - friend constexpr stdexec::forward_progress_guarantee - tag_invoke(stdexec::get_forward_progress_guarantee_t, scheduler self) noexcept { + friend constexpr auto + tag_invoke(stdexec::get_forward_progress_guarantee_t, scheduler self) noexcept + -> stdexec::forward_progress_guarantee { return self.forward_progress_guarantee(); } @@ -442,7 +442,7 @@ namespace tbbexec { }; [[nodiscard]] - scheduler get_scheduler() noexcept { + auto get_scheduler() noexcept -> scheduler { return scheduler{static_cast(*this)}; } @@ -456,7 +456,7 @@ namespace tbbexec { }*/ [[nodiscard]] - std::uint32_t available_parallelism() const { + auto available_parallelism() const -> std::uint32_t { return static_cast(*this).available_parallelism(); } @@ -516,12 +516,12 @@ namespace tbbexec { } [[nodiscard]] - std::uint32_t available_parallelism() const { + auto available_parallelism() const -> std::uint32_t { return static_cast(arena_.max_concurrency()); } private: [[nodiscard]] - static constexpr stdexec::forward_progress_guarantee forward_progress_guarantee() { + static constexpr auto forward_progress_guarantee() -> stdexec::forward_progress_guarantee { return stdexec::forward_progress_guarantee::parallel; } From e7738ad0cfc6ed0ce805c2e0c3156a6b5f367156 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Feb 2024 10:44:43 -0800 Subject: [PATCH 3/5] ignore clang-modernize commit --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 84a410b48..3ace792cf 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -15,3 +15,6 @@ ab2a3baef655db23fb7ec11ce7ec49575bbd2807 # replace all C-style casts with C++ casts; reformat 4410452fed3acda19d7b75b20ec2d3a3c92c9c38 + +# clang-modernize +3eaba4111bc8e8516ed1a4f516d753503b87e504 \ No newline at end of file From 1513e36dfb8d3cd654d521219a3f331de26387c9 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Feb 2024 10:45:07 -0800 Subject: [PATCH 4/5] add .clang-tidy file --- .clang-tidy | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..a97eacada --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,151 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,bugprone-*,modernize-*,-bugprone-reserved-identifier,-bugprone-unchecked-optional-access,-bugprone-macro-parentheses,-bugprone-easily-swappable-parameters' +WarningsAsErrors: '' +HeaderFileExtensions: + - '' + - h + - hh + - hpp + - hxx +ImplementationFileExtensions: + - c + - cc + - cpp + - cxx +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: none +User: eniebler +CheckOptions: + bugprone-argument-comment.CommentFloatLiterals: '0' + bugprone-argument-comment.CommentUserDefinedLiterals: '0' + modernize-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue' + modernize-use-bool-literals.IgnoreMacros: 'true' + bugprone-sizeof-expression.WarnOnSizeOfThis: 'true' + modernize-replace-auto-ptr.IncludeStyle: llvm + modernize-use-std-print.PrintfLikeFunctions: '::printf;absl::PrintF' + bugprone-suspicious-missing-comma.MaxConcatenatedTokens: '5' + bugprone-signed-char-misuse.CharTypdefsToIgnore: '' + modernize-make-unique.IgnoreMacros: 'true' + modernize-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque' + modernize-use-std-print.ReplacementPrintlnFunction: 'std::println' + modernize-use-noexcept.ReplacementString: '' + modernize-make-shared.IgnoreMacros: 'true' + modernize-loop-convert.MaxCopySize: '16' + bugprone-dangling-handle.HandleClasses: 'std::basic_string_view;std::experimental::basic_string_view' + modernize-loop-convert.MakeReverseRangeHeader: '' + llvm-else-after-return.WarnOnUnfixable: 'false' + bugprone-exception-escape.IgnoredExceptions: '' + bugprone-signal-handler.AsyncSafeFunctionSet: POSIX + bugprone-argument-comment.CommentIntegerLiterals: '0' + bugprone-argument-comment.CommentNullPtrs: '0' + cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false' + modernize-make-unique.MakeSmartPtrFunctionHeader: '' + modernize-make-unique.MakeSmartPtrFunction: 'std::make_unique' + modernize-deprecated-headers.CheckHeaderFile: 'false' + bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' + bugprone-argument-comment.CommentCharacterLiterals: '0' + modernize-make-unique.IncludeStyle: llvm + cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU' + bugprone-suspicious-missing-comma.RatioThreshold: '0.200000' + bugprone-string-constructor.LargeLengthThreshold: '8388608' + cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false' + bugprone-string-constructor.WarnOnLargeLength: 'true' + bugprone-argument-comment.StrictMode: '0' + modernize-use-std-print.IncludeStyle: llvm + modernize-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + modernize-loop-convert.MakeReverseRangeFunction: '' + bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit: '16' + modernize-use-std-print.PrintHeader: '' + modernize-use-override.FinalSpelling: final + bugprone-unused-return-value.CheckedFunctions: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname' + google-readability-namespace-comments.ShortNamespaceLines: '10' + modernize-replace-disallow-copy-and-assign-macro.MacroName: DISALLOW_COPY_AND_ASSIGN + bugprone-argument-comment.CommentStringLiterals: '0' + modernize-make-shared.IgnoreDefaultInitialization: 'true' + modernize-make-unique.IgnoreDefaultInitialization: 'true' + modernize-loop-convert.UseCxx20ReverseRanges: 'true' + bugprone-sizeof-expression.WarnOnSizeOfConstant: 'true' + bugprone-implicit-widening-of-multiplication-result.IncludeStyle: llvm + modernize-use-equals-default.IgnoreMacros: 'true' + modernize-loop-convert.IncludeStyle: llvm + bugprone-suspicious-include.HeaderFileExtensions: ';h;hh;hpp;hxx' + modernize-use-std-print.ReplacementPrintFunction: 'std::print' + modernize-use-override.IgnoreDestructors: 'false' + bugprone-empty-catch.AllowEmptyCatchForExceptions: '' + modernize-use-nullptr.NullMacros: 'NULL' + bugprone-argument-comment.CommentBoolLiterals: '0' + modernize-type-traits.IgnoreMacros: 'false' + modernize-use-std-print.StrictMode: 'false' + bugprone-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' + modernize-replace-random-shuffle.IncludeStyle: llvm + bugprone-stringview-nullptr.IncludeStyle: llvm + bugprone-narrowing-conversions.PedanticMode: 'false' + modernize-raw-string-literal.DelimiterStem: lit + bugprone-suspicious-enum-usage.StrictMode: 'false' + llvm-qualified-auto.AddConstToQualified: 'false' + bugprone-suspicious-include.ImplementationFileExtensions: 'c;cc;cpp;cxx' + bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression: 'false' + modernize-use-emplace.TupleTypes: '::std::pair;::std::tuple' + bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField: 'true' + bugprone-dynamic-static-initializers.HeaderFileExtensions: ';h;hh;hpp;hxx' + google-readability-braces-around-statements.ShortStatementLines: '1' + bugprone-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' + bugprone-argument-comment.IgnoreSingleArgument: '0' + bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' + bugprone-suspicious-missing-comma.SizeThreshold: '5' + modernize-use-std-print.FprintfLikeFunctions: '::fprintf;absl::FPrintF' + modernize-use-using.IgnoreMacros: 'true' + modernize-use-auto.MinTypeNameLength: '5' + bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' + modernize-use-override.IgnoreTemplateInstantiations: 'false' + modernize-loop-convert.MinConfidence: reasonable + bugprone-suspicious-string-compare.WarnOnLogicalNotComparison: 'false' + modernize-make-shared.MakeSmartPtrFunctionHeader: '' + modernize-use-emplace.IgnoreImplicitConstructors: 'false' + bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources: 'true' + bugprone-unsafe-functions.ReportMoreUnsafeFunctions: 'true' + cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true' + bugprone-suspicious-string-compare.StringCompareLikeFunctions: '' + google-readability-function-size.StatementThreshold: '800' + modernize-use-noexcept.UseNoexceptFalse: 'true' + bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources: 'true' + modernize-make-shared.IncludeStyle: llvm + bugprone-suspicious-string-compare.WarnOnImplicitComparison: 'true' + modernize-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace' + cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;' + bugprone-unused-return-value.CheckedReturnTypes: '::std::error_code;::std::error_condition;::std::errc;::std::expected;::boost::system::error_code' + bugprone-assert-side-effect.IgnoredFunctions: __builtin_expect + bugprone-string-constructor.StringNames: '::std::basic_string;::std::basic_string_view' + bugprone-exception-escape.FunctionsThatShouldNotThrow: '' + modernize-use-default-member-init.IgnoreMacros: 'true' + bugprone-misplaced-widening-cast.CheckImplicitCasts: 'false' + modernize-use-equals-delete.IgnoreMacros: 'true' + modernize-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque' + modernize-pass-by-value.ValuesOnly: 'false' + bugprone-not-null-terminated-result.WantToUseSafeFunctions: 'true' + modernize-use-override.AllowOverrideAndFinal: 'false' + bugprone-non-zero-enum-to-bool-conversion.EnumIgnoreList: '' + bugprone-narrowing-conversions.IgnoreConversionFromTypes: '' + bugprone-assert-side-effect.AssertMacros: assert,NSAssert,NSCAssert + modernize-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple' + modernize-raw-string-literal.ReplaceShorterLiterals: 'false' + bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant: 'true' + bugprone-empty-catch.IgnoreCatchWithKeywords: '@TODO;@FIXME' + modernize-use-nodiscard.ReplacementString: '[[nodiscard]]' + modernize-pass-by-value.IncludeStyle: llvm + google-readability-namespace-comments.SpacesBeforeComments: '2' + bugprone-assert-side-effect.CheckFunctionCalls: 'false' + bugprone-sizeof-expression.WarnOnSizeOfPointerToAggregate: 'true' + modernize-loop-convert.NamingStyle: CamelCase + modernize-avoid-bind.PermissiveParameterList: 'false' + modernize-make-shared.MakeSmartPtrFunction: 'std::make_shared' + modernize-use-auto.RemoveStars: 'false' + modernize-use-default-member-init.UseAssignment: 'false' + bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons: 'true' + llvm-else-after-return.WarnOnConditionVariables: 'false' + modernize-use-override.OverrideSpelling: override + modernize-use-transparent-functors.SafeMode: 'false' +SystemHeaders: false +... + From d449daa06a728fd906e39852e90de614938f4a15 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Feb 2024 10:45:44 -0800 Subject: [PATCH 5/5] fix some more issues found by clang-tidy --- include/exec/__detail/__sender_facade.hpp | 9 +++------ include/exec/any_sender_of.hpp | 7 +++++-- include/exec/static_thread_pool.hpp | 10 ++++++---- include/exec/task.hpp | 4 ++-- include/stdexec/__detail/__env.hpp | 2 +- include/stdexec/execution.hpp | 12 ++++++++---- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/exec/__detail/__sender_facade.hpp b/include/exec/__detail/__sender_facade.hpp index 49e36c58a..7ce013bc4 100644 --- a/include/exec/__detail/__sender_facade.hpp +++ b/include/exec/__detail/__sender_facade.hpp @@ -303,12 +303,9 @@ namespace exec { if constexpr (__mvalid<__pre_completions_t, _NewSender, _NewEnv>) { using _Completions = __completions_t<_NewEnv, __pre_completions_t<_NewSender, _NewEnv>>; - if constexpr (__valid_completion_signatures<_Completions>) { - return static_cast<_Completions (*)()>(nullptr); - } else { - // assume this is an error message and return it directly - return static_cast<_Completions (*)()>(nullptr); - } + // either this is a valid completion signature or an error message. + // either way, return it directly. + return static_cast<_Completions (*)()>(nullptr); } else { return static_cast<__diagnostic_t<_Env> (*)()>(nullptr); } diff --git a/include/exec/any_sender_of.hpp b/include/exec/any_sender_of.hpp index 253bdfebc..555010a3a 100644 --- a/include/exec/any_sender_of.hpp +++ b/include/exec/any_sender_of.hpp @@ -450,8 +450,11 @@ namespace exec { auto operator=(const __t& __other) -> __t& requires(_Copyable) { - __t tmp(__other); - return *this = std::move(tmp); + if (&__other != this) { + __t tmp(__other); + *this = std::move(tmp); + } + return *this; } __t(__t&& __other) noexcept { diff --git a/include/exec/static_thread_pool.hpp b/include/exec/static_thread_pool.hpp index fb15f03c2..78f17e3a6 100644 --- a/include/exec/static_thread_pool.hpp +++ b/include/exec/static_thread_pool.hpp @@ -742,7 +742,7 @@ namespace exec { inline auto static_thread_pool_::num_threads(nodemask constraints) const noexcept -> std::size_t { - const auto nNodes = static_cast(threadIndexByNumaNode_.back().numa_node + 1); + const std::size_t nNodes = static_cast(threadIndexByNumaNode_.back().numa_node + 1); std::size_t nThreads = 0; for (std::size_t nodeIndex = 0; nodeIndex < nNodes; ++nodeIndex) { if (!constraints[nodeIndex]) { @@ -1028,10 +1028,12 @@ namespace exec { auto stoken = get_stop_token(get_env(op.rcvr_)); if constexpr (stdexec::unstoppable_token) { set_value(static_cast(op.rcvr_)); - } else if (stoken.stop_requested()) { - set_stopped(static_cast(op.rcvr_)); } else { - set_value(static_cast(op.rcvr_)); + if (stoken.stop_requested()) { + set_stopped(static_cast(op.rcvr_)); + } else { + set_value(static_cast(op.rcvr_)); + } } }; } diff --git a/include/exec/task.hpp b/include/exec/task.hpp index eb1bb8a70..9e1fbadf7 100644 --- a/include/exec/task.hpp +++ b/include/exec/task.hpp @@ -278,7 +278,7 @@ namespace exec { // In a base class so it can be specialized when _Ty is void: template struct __promise_base { - void return_value(_Ty value) noexcept { + void return_value(_Ty value) { __data_.template emplace<1>(std::move(value)); } @@ -289,7 +289,7 @@ namespace exec { struct __promise_base { struct __void { }; - void return_void() noexcept { + void return_void() { __data_.template emplace<1>(__void{}); } diff --git a/include/stdexec/__detail/__env.hpp b/include/stdexec/__detail/__env.hpp index 160309590..628d69a0b 100644 --- a/include/stdexec/__detail/__env.hpp +++ b/include/stdexec/__detail/__env.hpp @@ -112,7 +112,7 @@ namespace stdexec { constexpr auto operator()(_Tp&&) const noexcept(noexcept(__result_t<_Tp>{})) -> __result_t<_Tp> { using _Boolean = tag_invoke_result_t<__has_algorithm_customizations_t, __cref_t<_Tp>>; - static_assert(_Boolean{} ? true : true); // must be contextually convertible to bool + static_assert(_Boolean{} ? true : false); // must be contextually convertible to bool return _Boolean{}; } diff --git a/include/stdexec/execution.hpp b/include/stdexec/execution.hpp index 037997061..f73937824 100644 --- a/include/stdexec/execution.hpp +++ b/include/stdexec/execution.hpp @@ -1691,15 +1691,18 @@ namespace stdexec { using _Result = tag_invoke_result_t; constexpr bool _Nothrow = nothrow_tag_invocable; return static_cast<_Result (*)() noexcept(_Nothrow)>(nullptr); + // NOLINTNEXTLINE(bugprone-branch-clone) } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !! - return static_cast < _Tp && (*) () noexcept > (nullptr); + using _Result = _Tp&&; + return static_cast<_Result (*)() noexcept>(nullptr); } else if constexpr (__awaitable_sender<_Tp, _Promise>) { using _Result = __sender_awaitable_t<_Promise, _Tp>; constexpr bool _Nothrow = __nothrow_constructible_from<_Result, _Tp, __coro::coroutine_handle<_Promise>>; return static_cast<_Result (*)() noexcept(_Nothrow)>(nullptr); } else { - return static_cast < _Tp && (*) () noexcept > (nullptr); + using _Result = _Tp&&; + return static_cast<_Result (*)() noexcept>(nullptr); } } template @@ -1713,6 +1716,7 @@ namespace stdexec { using _Result = tag_invoke_result_t; static_assert(__awaitable<_Result, _Promise>); return tag_invoke(*this, static_cast<_Tp&&>(__t), __promise); + // NOLINTNEXTLINE(bugprone-branch-clone) } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !! return static_cast<_Tp&&>(__t); } else if constexpr (__awaitable_sender<_Tp, _Promise>) { @@ -2987,11 +2991,11 @@ namespace stdexec { }; template - auto __notify_visitor(_Receiver&& __rcvr) noexcept { + auto __notify_visitor(_Receiver& __rcvr) noexcept { return [&](_Tuple&& __tupl) noexcept -> void { __apply( [&](auto __tag, auto&&... __args) noexcept -> void { - __tag(std::move(__rcvr), __forward_like<_Tuple>(__args)...); + __tag(static_cast<_Receiver&&>(__rcvr), __forward_like<_Tuple>(__args)...); }, __tupl); };