diff --git a/third/asio.hpp b/third/asio.hpp index 36fa9b2d2..3421b58bd 100644 --- a/third/asio.hpp +++ b/third/asio.hpp @@ -2,7 +2,7 @@ // asio.hpp // ~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -21,8 +21,9 @@ #include "asio/append.hpp" #include "asio/as_tuple.hpp" #include "asio/associated_allocator.hpp" -#include "asio/associated_executor.hpp" #include "asio/associated_cancellation_slot.hpp" +#include "asio/associated_executor.hpp" +#include "asio/associated_immediate_executor.hpp" #include "asio/associator.hpp" #include "asio/async_result.hpp" #include "asio/awaitable.hpp" @@ -48,6 +49,7 @@ #include "asio/bind_allocator.hpp" #include "asio/bind_cancellation_slot.hpp" #include "asio/bind_executor.hpp" +#include "asio/bind_immediate_executor.hpp" #include "asio/buffer.hpp" #include "asio/buffer_registration.hpp" #include "asio/buffered_read_stream_fwd.hpp" @@ -79,30 +81,15 @@ #include "asio/execution/any_executor.hpp" #include "asio/execution/blocking.hpp" #include "asio/execution/blocking_adaptation.hpp" -#include "asio/execution/bulk_execute.hpp" -#include "asio/execution/bulk_guarantee.hpp" -#include "asio/execution/connect.hpp" #include "asio/execution/context.hpp" #include "asio/execution/context_as.hpp" -#include "asio/execution/execute.hpp" #include "asio/execution/executor.hpp" #include "asio/execution/invocable_archetype.hpp" #include "asio/execution/mapping.hpp" #include "asio/execution/occupancy.hpp" -#include "asio/execution/operation_state.hpp" #include "asio/execution/outstanding_work.hpp" #include "asio/execution/prefer_only.hpp" -#include "asio/execution/receiver.hpp" -#include "asio/execution/receiver_invocation_error.hpp" #include "asio/execution/relationship.hpp" -#include "asio/execution/schedule.hpp" -#include "asio/execution/scheduler.hpp" -#include "asio/execution/sender.hpp" -#include "asio/execution/set_done.hpp" -#include "asio/execution/set_error.hpp" -#include "asio/execution/set_value.hpp" -#include "asio/execution/start.hpp" -#include "asio/execution_context.hpp" #include "asio/executor.hpp" #include "asio/executor_work_guard.hpp" #include "asio/file_base.hpp" @@ -111,9 +98,7 @@ #include "asio/generic/raw_protocol.hpp" #include "asio/generic/seq_packet_protocol.hpp" #include "asio/generic/stream_protocol.hpp" -#include "asio/handler_alloc_hook.hpp" #include "asio/handler_continuation_hook.hpp" -#include "asio/handler_invoke_hook.hpp" #include "asio/high_resolution_timer.hpp" #include "asio/io_context.hpp" #include "asio/io_context_strand.hpp" @@ -151,6 +136,7 @@ #include "asio/local/basic_endpoint.hpp" #include "asio/local/connect_pair.hpp" #include "asio/local/datagram_protocol.hpp" +#include "asio/local/seq_packet_protocol.hpp" #include "asio/local/stream_protocol.hpp" #include "asio/multiple_exceptions.hpp" #include "asio/packaged_task.hpp" @@ -177,6 +163,7 @@ #include "asio/serial_port.hpp" #include "asio/serial_port_base.hpp" #include "asio/signal_set.hpp" +#include "asio/signal_set_base.hpp" #include "asio/socket_base.hpp" #include "asio/static_thread_pool.hpp" #include "asio/steady_timer.hpp" diff --git a/third/asio/any_completion_executor.hpp b/third/asio/any_completion_executor.hpp index 5fdb6917c..650ff7baf 100644 --- a/third/asio/any_completion_executor.hpp +++ b/third/asio/any_completion_executor.hpp @@ -2,7 +2,7 @@ // any_completion_executor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -75,20 +75,18 @@ class any_completion_executor : #endif // !defined(GENERATING_DOCUMENTATION) /// Default constructor. - ASIO_DECL any_completion_executor() ASIO_NOEXCEPT; + ASIO_DECL any_completion_executor() noexcept; /// Construct in an empty state. Equivalent effects to default constructor. - ASIO_DECL any_completion_executor(nullptr_t) ASIO_NOEXCEPT; + ASIO_DECL any_completion_executor(nullptr_t) noexcept; /// Copy constructor. ASIO_DECL any_completion_executor( - const any_completion_executor& e) ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move constructor. ASIO_DECL any_completion_executor( - any_completion_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + any_completion_executor&& e) noexcept; /// Construct to point to the same target as another any_executor. #if defined(GENERATING_DOCUMENTATION) @@ -98,7 +96,7 @@ class any_completion_executor : #else // defined(GENERATING_DOCUMENTATION) template any_completion_executor(OtherAnyExecutor e, - typename constraint< + constraint_t< conditional< !is_same::value && is_base_of, false_type >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -122,7 +120,7 @@ class any_completion_executor : #else // defined(GENERATING_DOCUMENTATION) template any_completion_executor(std::nothrow_t, OtherAnyExecutor e, - typename constraint< + constraint_t< conditional< !is_same::value && is_base_of, false_type >::type::value - >::type = 0) ASIO_NOEXCEPT - : base_type(std::nothrow, ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. ASIO_DECL any_completion_executor(std::nothrow_t, - const any_completion_executor& e) ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. ASIO_DECL any_completion_executor(std::nothrow_t, - any_completion_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + any_completion_executor&& e) noexcept; /// Construct a polymorphic wrapper for the specified executor. #if defined(GENERATING_DOCUMENTATION) @@ -155,7 +151,7 @@ class any_completion_executor : #else // defined(GENERATING_DOCUMENTATION) template any_completion_executor(Executor e, - typename constraint< + constraint_t< conditional< !is_same::value && !is_base_of, false_type >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(Executor)(e)) + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -177,7 +173,7 @@ class any_completion_executor : #else // defined(GENERATING_DOCUMENTATION) template any_completion_executor(std::nothrow_t, Executor e, - typename constraint< + constraint_t< conditional< !is_same::value && !is_base_of, false_type >::type::value - >::type = 0) ASIO_NOEXCEPT - : base_type(std::nothrow, ASIO_MOVE_CAST(Executor)(e)) + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Assignment operator. ASIO_DECL any_completion_executor& operator=( - const any_completion_executor& e) ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move assignment operator. ASIO_DECL any_completion_executor& operator=( - any_completion_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + any_completion_executor&& e) noexcept; /// Assignment operator that sets the polymorphic wrapper to the empty state. ASIO_DECL any_completion_executor& operator=(nullptr_t); @@ -209,7 +203,7 @@ class any_completion_executor : ASIO_DECL ~any_completion_executor(); /// Swap targets with another polymorphic wrapper. - ASIO_DECL void swap(any_completion_executor& other) ASIO_NOEXCEPT; + ASIO_DECL void swap(any_completion_executor& other) noexcept; /// Obtain a polymorphic wrapper with the specified property. /** @@ -222,9 +216,9 @@ class any_completion_executor : */ template any_completion_executor require(const Property& p, - typename constraint< + constraint_t< traits::require_member::is_valid - >::type = 0) const + > = 0) const { return static_cast(*this).require(p); } @@ -240,9 +234,9 @@ class any_completion_executor : */ template any_completion_executor prefer(const Property& p, - typename constraint< + constraint_t< traits::prefer_member::is_valid - >::type = 0) const + > = 0) const { return static_cast(*this).prefer(p); } diff --git a/third/asio/any_completion_handler.hpp b/third/asio/any_completion_handler.hpp index d7522bd2c..45b3e75fe 100644 --- a/third/asio/any_completion_handler.hpp +++ b/third/asio/any_completion_handler.hpp @@ -2,7 +2,7 @@ // any_completion_handler.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,20 +12,16 @@ #define ASIO_ANY_COMPLETION_HANDLER_HPP #include "asio/detail/config.hpp" - -#if (defined(ASIO_HAS_STD_TUPLE) \ - && defined(ASIO_HAS_MOVE) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include #include #include #include #include "asio/any_completion_executor.hpp" +#include "asio/any_io_executor.hpp" #include "asio/associated_allocator.hpp" #include "asio/associated_cancellation_slot.hpp" #include "asio/associated_executor.hpp" +#include "asio/associated_immediate_executor.hpp" #include "asio/cancellation_state.hpp" #include "asio/recycling_allocator.hpp" @@ -39,11 +35,11 @@ class any_completion_handler_impl_base public: template explicit any_completion_handler_impl_base(S&& slot) - : cancel_state_(ASIO_MOVE_CAST(S)(slot), enable_total_cancellation()) + : cancel_state_(static_cast(slot), enable_total_cancellation()) { } - cancellation_slot get_cancellation_slot() const ASIO_NOEXCEPT + cancellation_slot get_cancellation_slot() const noexcept { return cancel_state_.slot(); } @@ -59,8 +55,8 @@ class any_completion_handler_impl : public: template any_completion_handler_impl(S&& slot, H&& h) - : any_completion_handler_impl_base(ASIO_MOVE_CAST(S)(slot)), - handler_(ASIO_MOVE_CAST(H)(h)) + : any_completion_handler_impl_base(static_cast(slot)), + handler_(static_cast(h)) { } @@ -103,7 +99,7 @@ class any_completion_handler_impl : any_completion_handler_impl* ptr = new (uninit_ptr.get()) any_completion_handler_impl( - ASIO_MOVE_CAST(S)(slot), ASIO_MOVE_CAST(H)(h)); + static_cast(slot), static_cast(h)); uninit_ptr.release(); return ptr; @@ -119,12 +115,19 @@ class any_completion_handler_impl : } any_completion_executor executor( - const any_completion_executor& candidate) const ASIO_NOEXCEPT + const any_completion_executor& candidate) const noexcept { return any_completion_executor(std::nothrow, (get_associated_executor)(handler_, candidate)); } + any_completion_executor immediate_executor( + const any_io_executor& candidate) const noexcept + { + return any_completion_executor(std::nothrow, + (get_associated_immediate_executor)(handler_, candidate)); + } + void* allocate(std::size_t size, std::size_t align) const { typename std::allocator_traits< @@ -180,11 +183,11 @@ class any_completion_handler_impl : asio::recycling_allocator())}; std::unique_ptr ptr(this, d); - Handler handler(ASIO_MOVE_CAST(Handler)(handler_)); + Handler handler(static_cast(handler_)); ptr.reset(); - ASIO_MOVE_CAST(Handler)(handler)( - ASIO_MOVE_CAST(Args)(args)...); + static_cast(handler)( + static_cast(args)...); } private: @@ -207,14 +210,14 @@ class any_completion_handler_call_fn void call(any_completion_handler_impl_base* impl, Args... args) const { - call_fn_(impl, ASIO_MOVE_CAST(Args)(args)...); + call_fn_(impl, static_cast(args)...); } template static void impl(any_completion_handler_impl_base* impl, Args... args) { static_cast*>(impl)->call( - ASIO_MOVE_CAST(Args)(args)...); + static_cast(args)...); } private: @@ -305,6 +308,36 @@ class any_completion_handler_executor_fn type executor_fn_; }; +class any_completion_handler_immediate_executor_fn +{ +public: + using type = any_completion_executor(*)( + any_completion_handler_impl_base*, const any_io_executor&); + + constexpr any_completion_handler_immediate_executor_fn(type fn) + : immediate_executor_fn_(fn) + { + } + + any_completion_executor immediate_executor( + any_completion_handler_impl_base* impl, + const any_io_executor& candidate) const + { + return immediate_executor_fn_(impl, candidate); + } + + template + static any_completion_executor impl(any_completion_handler_impl_base* impl, + const any_io_executor& candidate) + { + return static_cast*>( + impl)->immediate_executor(candidate); + } + +private: + type immediate_executor_fn_; +}; + class any_completion_handler_allocate_fn { public: @@ -367,6 +400,7 @@ template class any_completion_handler_fn_table : private any_completion_handler_destroy_fn, private any_completion_handler_executor_fn, + private any_completion_handler_immediate_executor_fn, private any_completion_handler_allocate_fn, private any_completion_handler_deallocate_fn, private any_completion_handler_call_fns @@ -376,11 +410,13 @@ class any_completion_handler_fn_table constexpr any_completion_handler_fn_table( any_completion_handler_destroy_fn::type destroy_fn, any_completion_handler_executor_fn::type executor_fn, + any_completion_handler_immediate_executor_fn::type immediate_executor_fn, any_completion_handler_allocate_fn::type allocate_fn, any_completion_handler_deallocate_fn::type deallocate_fn, CallFns... call_fns) : any_completion_handler_destroy_fn(destroy_fn), any_completion_handler_executor_fn(executor_fn), + any_completion_handler_immediate_executor_fn(immediate_executor_fn), any_completion_handler_allocate_fn(allocate_fn), any_completion_handler_deallocate_fn(deallocate_fn), any_completion_handler_call_fns(call_fns...) @@ -389,6 +425,7 @@ class any_completion_handler_fn_table using any_completion_handler_destroy_fn::destroy; using any_completion_handler_executor_fn::executor; + using any_completion_handler_immediate_executor_fn::immediate_executor; using any_completion_handler_allocate_fn::allocate; using any_completion_handler_deallocate_fn::deallocate; using any_completion_handler_call_fns::call; @@ -401,6 +438,7 @@ struct any_completion_handler_fn_table_instance value = any_completion_handler_fn_table( &any_completion_handler_destroy_fn::impl, &any_completion_handler_executor_fn::impl, + &any_completion_handler_immediate_executor_fn::impl, &any_completion_handler_allocate_fn::impl, &any_completion_handler_deallocate_fn::impl, &any_completion_handler_call_fn::template impl...); @@ -415,6 +453,8 @@ any_completion_handler_fn_table_instance::value; template class any_completion_handler; +/// An allocator type that forwards memory allocation operations through an +/// instance of @c any_completion_handler. template class any_completion_handler_allocator { @@ -429,55 +469,72 @@ class any_completion_handler_allocator detail::any_completion_handler_impl_base* impl_; constexpr any_completion_handler_allocator(int, - const any_completion_handler& h) ASIO_NOEXCEPT + const any_completion_handler& h) noexcept : fn_table_(h.fn_table_), impl_(h.impl_) { } public: + /// The type of objects that may be allocated by the allocator. typedef T value_type; + /// Rebinds an allocator to another value type. template struct rebind { + /// Specifies the type of the rebound allocator. typedef any_completion_handler_allocator other; }; + /// Construct from another @c any_completion_handler_allocator. template constexpr any_completion_handler_allocator( const any_completion_handler_allocator& a) - ASIO_NOEXCEPT + noexcept : fn_table_(a.fn_table_), impl_(a.impl_) { } + /// Equality operator. constexpr bool operator==( - const any_completion_handler_allocator& other) const ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ == other.fn_table_ && impl_ == other.impl_; } + /// Inequality operator. constexpr bool operator!=( - const any_completion_handler_allocator& other) const ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ != other.fn_table_ || impl_ != other.impl_; } + /// Allocate space for @c n objects of the allocator's value type. T* allocate(std::size_t n) const { - return static_cast( - fn_table_->allocate( - impl_, sizeof(T) * n, alignof(T))); + if (fn_table_) + { + return static_cast( + fn_table_->allocate( + impl_, sizeof(T) * n, alignof(T))); + } + std::bad_alloc ex; + asio::detail::throw_exception(ex); + return nullptr; } + /// Deallocate space for @c n objects of the allocator's value type. void deallocate(T* p, std::size_t n) const { fn_table_->deallocate(impl_, p, sizeof(T) * n, alignof(T)); } }; +/// A protoco-allocator type that may be rebound to obtain an allocator that +/// forwards memory allocation operations through an instance of +/// @c any_completion_handler. template class any_completion_handler_allocator { @@ -492,46 +549,70 @@ class any_completion_handler_allocator detail::any_completion_handler_impl_base* impl_; constexpr any_completion_handler_allocator(int, - const any_completion_handler& h) ASIO_NOEXCEPT + const any_completion_handler& h) noexcept : fn_table_(h.fn_table_), impl_(h.impl_) { } public: + /// @c void as no objects can be allocated through a proto-allocator. typedef void value_type; + /// Rebinds an allocator to another value type. template struct rebind { + /// Specifies the type of the rebound allocator. typedef any_completion_handler_allocator other; }; + /// Construct from another @c any_completion_handler_allocator. template constexpr any_completion_handler_allocator( const any_completion_handler_allocator& a) - ASIO_NOEXCEPT + noexcept : fn_table_(a.fn_table_), impl_(a.impl_) { } + /// Equality operator. constexpr bool operator==( - const any_completion_handler_allocator& other) const ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ == other.fn_table_ && impl_ == other.impl_; } + /// Inequality operator. constexpr bool operator!=( - const any_completion_handler_allocator& other) const ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ != other.fn_table_ || impl_ != other.impl_; } }; +/// Polymorphic wrapper for completion handlers. +/** + * The @c any_completion_handler class template is a polymorphic wrapper for + * completion handlers that propagates the associated executor, associated + * allocator, and associated cancellation slot through a type-erasing interface. + * + * When using @c any_completion_handler, specify one or more completion + * signatures as template parameters. These will dictate the arguments that may + * be passed to the handler through the polymorphic interface. + * + * Typical uses for @c any_completion_handler include: + * + * @li Separate compilation of asynchronous operation implementations. + * + * @li Enabling interoperability between asynchronous operations and virtual + * functions. + */ template class any_completion_handler { +#if !defined(GENERATING_DOCUMENTATION) private: template friend class any_completion_handler_allocator; @@ -539,36 +620,55 @@ class any_completion_handler template friend struct associated_executor; + template + friend struct associated_immediate_executor; + const detail::any_completion_handler_fn_table* fn_table_; detail::any_completion_handler_impl_base* impl_; +#endif // !defined(GENERATING_DOCUMENTATION) public: + /// The associated allocator type. using allocator_type = any_completion_handler_allocator; + + /// The associated cancellation slot type. using cancellation_slot_type = cancellation_slot; + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. constexpr any_completion_handler() : fn_table_(nullptr), impl_(nullptr) { } + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. constexpr any_completion_handler(nullptr_t) : fn_table_(nullptr), impl_(nullptr) { } - template ::type> - any_completion_handler(H&& h) + /// Construct an @c any_completion_handler to contain the specified target. + template > + any_completion_handler(H&& h, + constraint_t< + !is_same, any_completion_handler>::value + > = 0) : fn_table_( &detail::any_completion_handler_fn_table_instance< Handler, Signatures...>::value), impl_(detail::any_completion_handler_impl::create( - (get_associated_cancellation_slot)(h), ASIO_MOVE_CAST(H)(h))) + (get_associated_cancellation_slot)(h), static_cast(h))) { } - any_completion_handler(any_completion_handler&& other) ASIO_NOEXCEPT + /// Move-construct an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ + any_completion_handler(any_completion_handler&& other) noexcept : fn_table_(other.fn_table_), impl_(other.impl_) { @@ -576,84 +676,109 @@ class any_completion_handler other.impl_ = nullptr; } + /// Move-assign an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ any_completion_handler& operator=( - any_completion_handler&& other) ASIO_NOEXCEPT + any_completion_handler&& other) noexcept { - any_completion_handler(other).swap(*this); + any_completion_handler( + static_cast(other)).swap(*this); return *this; } - any_completion_handler& operator=(nullptr_t) ASIO_NOEXCEPT + /// Assignment operator that sets the polymorphic wrapper to the empty state. + any_completion_handler& operator=(nullptr_t) noexcept { any_completion_handler().swap(*this); return *this; } + /// Destructor. ~any_completion_handler() { if (impl_) fn_table_->destroy(impl_); } - constexpr explicit operator bool() const ASIO_NOEXCEPT + /// Test if the polymorphic wrapper is empty. + constexpr explicit operator bool() const noexcept { return impl_ != nullptr; } - constexpr bool operator!() const ASIO_NOEXCEPT + /// Test if the polymorphic wrapper is non-empty. + constexpr bool operator!() const noexcept { return impl_ == nullptr; } - void swap(any_completion_handler& other) ASIO_NOEXCEPT + /// Swap the content of an @c any_completion_handler with another. + void swap(any_completion_handler& other) noexcept { std::swap(fn_table_, other.fn_table_); std::swap(impl_, other.impl_); } - allocator_type get_allocator() const ASIO_NOEXCEPT + /// Get the associated allocator. + allocator_type get_allocator() const noexcept { return allocator_type(0, *this); } - cancellation_slot_type get_cancellation_slot() const ASIO_NOEXCEPT + /// Get the associated cancellation slot. + cancellation_slot_type get_cancellation_slot() const noexcept { - return impl_->get_cancellation_slot(); + return impl_ ? impl_->get_cancellation_slot() : cancellation_slot_type(); } + /// Function call operator. + /** + * Invokes target completion handler with the supplied arguments. + * + * This function may only be called once, as the target handler is moved from. + * The polymorphic wrapper is left in an empty state. + * + * Throws @c std::bad_function_call if the polymorphic wrapper is empty. + */ template auto operator()(Args&&... args) - -> decltype(fn_table_->call(impl_, ASIO_MOVE_CAST(Args)(args)...)) + -> decltype(fn_table_->call(impl_, static_cast(args)...)) { if (detail::any_completion_handler_impl_base* impl = impl_) { impl_ = nullptr; - return fn_table_->call(impl, ASIO_MOVE_CAST(Args)(args)...); + return fn_table_->call(impl, static_cast(args)...); } std::bad_function_call ex; asio::detail::throw_exception(ex); } + /// Equality operator. friend constexpr bool operator==( - const any_completion_handler& a, nullptr_t) ASIO_NOEXCEPT + const any_completion_handler& a, nullptr_t) noexcept { return a.impl_ == nullptr; } + /// Equality operator. friend constexpr bool operator==( - nullptr_t, const any_completion_handler& b) ASIO_NOEXCEPT + nullptr_t, const any_completion_handler& b) noexcept { return nullptr == b.impl_; } + /// Inequality operator. friend constexpr bool operator!=( - const any_completion_handler& a, nullptr_t) ASIO_NOEXCEPT + const any_completion_handler& a, nullptr_t) noexcept { return a.impl_ != nullptr; } + /// Inequality operator. friend constexpr bool operator!=( - nullptr_t, const any_completion_handler& b) ASIO_NOEXCEPT + nullptr_t, const any_completion_handler& b) noexcept { return nullptr != b.impl_; } @@ -665,10 +790,28 @@ struct associated_executor, Candidate> using type = any_completion_executor; static type get(const any_completion_handler& handler, - const Candidate& candidate = Candidate()) ASIO_NOEXCEPT + const Candidate& candidate = Candidate()) noexcept { - return handler.fn_table_->executor(handler.impl_, - any_completion_executor(std::nothrow, candidate)); + any_completion_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->executor(handler.impl_, any_candidate) + : any_candidate; + } +}; + +template +struct associated_immediate_executor< + any_completion_handler, Candidate> +{ + using type = any_completion_executor; + + static type get(const any_completion_handler& handler, + const Candidate& candidate = Candidate()) noexcept + { + any_io_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->immediate_executor(handler.impl_, any_candidate) + : any_candidate; } }; @@ -676,9 +819,4 @@ struct associated_executor, Candidate> #include "asio/detail/pop_options.hpp" -#endif // (defined(ASIO_HAS_STD_TUPLE) - // && defined(ASIO_HAS_MOVE) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // ASIO_ANY_COMPLETION_HANDLER_HPP diff --git a/third/asio/any_io_executor.hpp b/third/asio/any_io_executor.hpp index 829b968e7..d35acf44a 100644 --- a/third/asio/any_io_executor.hpp +++ b/third/asio/any_io_executor.hpp @@ -2,7 +2,7 @@ // any_io_executor.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -87,18 +87,16 @@ class any_io_executor : #endif // !defined(GENERATING_DOCUMENTATION) /// Default constructor. - ASIO_DECL any_io_executor() ASIO_NOEXCEPT; + ASIO_DECL any_io_executor() noexcept; /// Construct in an empty state. Equivalent effects to default constructor. - ASIO_DECL any_io_executor(nullptr_t) ASIO_NOEXCEPT; + ASIO_DECL any_io_executor(nullptr_t) noexcept; /// Copy constructor. - ASIO_DECL any_io_executor(const any_io_executor& e) ASIO_NOEXCEPT; + ASIO_DECL any_io_executor(const any_io_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move constructor. - ASIO_DECL any_io_executor(any_io_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + ASIO_DECL any_io_executor(any_io_executor&& e) noexcept; /// Construct to point to the same target as another any_executor. #if defined(GENERATING_DOCUMENTATION) @@ -107,8 +105,8 @@ class any_io_executor : #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(OtherAnyExecutor e, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value && is_base_of::value, @@ -116,9 +114,9 @@ class any_io_executor : 0, supportable_properties_type>::template is_valid_target, false_type - >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + >::value + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -131,8 +129,8 @@ class any_io_executor : #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(std::nothrow_t, OtherAnyExecutor e, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value && is_base_of::value, @@ -140,22 +138,19 @@ class any_io_executor : 0, supportable_properties_type>::template is_valid_target, false_type - >::type::value - >::type = 0) ASIO_NOEXCEPT - : base_type(std::nothrow, ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + >::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. ASIO_DECL any_io_executor(std::nothrow_t, - const any_io_executor& e) ASIO_NOEXCEPT; + const any_io_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. - ASIO_DECL any_io_executor(std::nothrow_t, - any_io_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + ASIO_DECL any_io_executor(std::nothrow_t, any_io_executor&& e) noexcept; /// Construct a polymorphic wrapper for the specified executor. #if defined(GENERATING_DOCUMENTATION) @@ -164,17 +159,17 @@ class any_io_executor : #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(Executor e, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value && !is_base_of::value, execution::detail::is_valid_target_executor< Executor, supportable_properties_type>, false_type - >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(Executor)(e)) + >::value + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -186,30 +181,27 @@ class any_io_executor : #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(std::nothrow_t, Executor e, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value && !is_base_of::value, execution::detail::is_valid_target_executor< Executor, supportable_properties_type>, false_type - >::type::value - >::type = 0) ASIO_NOEXCEPT - : base_type(std::nothrow, ASIO_MOVE_CAST(Executor)(e)) + >::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Assignment operator. ASIO_DECL any_io_executor& operator=( - const any_io_executor& e) ASIO_NOEXCEPT; + const any_io_executor& e) noexcept; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move assignment operator. - ASIO_DECL any_io_executor& operator=( - any_io_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + ASIO_DECL any_io_executor& operator=(any_io_executor&& e) noexcept; /// Assignment operator that sets the polymorphic wrapper to the empty state. ASIO_DECL any_io_executor& operator=(nullptr_t); @@ -218,7 +210,7 @@ class any_io_executor : ASIO_DECL ~any_io_executor(); /// Swap targets with another polymorphic wrapper. - ASIO_DECL void swap(any_io_executor& other) ASIO_NOEXCEPT; + ASIO_DECL void swap(any_io_executor& other) noexcept; /// Obtain a polymorphic wrapper with the specified property. /** @@ -231,9 +223,9 @@ class any_io_executor : */ template any_io_executor require(const Property& p, - typename constraint< + constraint_t< traits::require_member::is_valid - >::type = 0) const + > = 0) const { return static_cast(*this).require(p); } @@ -249,9 +241,9 @@ class any_io_executor : */ template any_io_executor prefer(const Property& p, - typename constraint< + constraint_t< traits::prefer_member::is_valid - >::type = 0) const + > = 0) const { return static_cast(*this).prefer(p); } diff --git a/third/asio/append.hpp b/third/asio/append.hpp index 227de90ff..046089242 100644 --- a/third/asio/append.hpp +++ b/third/asio/append.hpp @@ -2,7 +2,7 @@ // append.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,11 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" - -#if (defined(ASIO_HAS_STD_TUPLE) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include #include "asio/detail/type_traits.hpp" @@ -37,11 +32,9 @@ class append_t public: /// Constructor. template - ASIO_CONSTEXPR explicit append_t( - ASIO_MOVE_ARG(T) completion_token, - ASIO_MOVE_ARG(V)... values) - : token_(ASIO_MOVE_CAST(T)(completion_token)), - values_(ASIO_MOVE_CAST(V)(values)...) + constexpr explicit append_t(T&& completion_token, V&&... values) + : token_(static_cast(completion_token)), + values_(static_cast(values)...) { } @@ -54,15 +47,13 @@ class append_t /// arguments should be passed additional values after the results of the /// operation. template -ASIO_NODISCARD inline ASIO_CONSTEXPR append_t< - typename decay::type, typename decay::type...> -append(ASIO_MOVE_ARG(CompletionToken) completion_token, - ASIO_MOVE_ARG(Values)... values) +ASIO_NODISCARD inline constexpr +append_t, decay_t...> +append(CompletionToken&& completion_token, Values&&... values) { - return append_t< - typename decay::type, typename decay::type...>( - ASIO_MOVE_CAST(CompletionToken)(completion_token), - ASIO_MOVE_CAST(Values)(values)...); + return append_t, decay_t...>( + static_cast(completion_token), + static_cast(values)...); } } // namespace asio @@ -71,8 +62,4 @@ append(ASIO_MOVE_ARG(CompletionToken) completion_token, #include "asio/impl/append.hpp" -#endif // (defined(ASIO_HAS_STD_TUPLE) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // ASIO_APPEND_HPP diff --git a/third/asio/as_tuple.hpp b/third/asio/as_tuple.hpp index 0629033b8..60008bda5 100644 --- a/third/asio/as_tuple.hpp +++ b/third/asio/as_tuple.hpp @@ -2,7 +2,7 @@ // as_tuple.hpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,11 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" - -#if (defined(ASIO_HAS_STD_TUPLE) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include "asio/detail/type_traits.hpp" #include "asio/detail/push_options.hpp" @@ -50,18 +45,18 @@ class as_tuple_t * token is itself defaulted as an argument to allow it to capture a source * location. */ - ASIO_CONSTEXPR as_tuple_t( + constexpr as_tuple_t( default_constructor_tag = default_constructor_tag(), CompletionToken token = CompletionToken()) - : token_(ASIO_MOVE_CAST(CompletionToken)(token)) + : token_(static_cast(token)) { } /// Constructor. template - ASIO_CONSTEXPR explicit as_tuple_t( - ASIO_MOVE_ARG(T) completion_token) - : token_(ASIO_MOVE_CAST(T)(completion_token)) + constexpr explicit as_tuple_t( + T&& completion_token) + : token_(static_cast(completion_token)) { } @@ -76,13 +71,13 @@ class as_tuple_t /// Construct the adapted executor from the inner executor type. template executor_with_default(const InnerExecutor1& ex, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value, is_convertible, false_type - >::type::value - >::type = 0) ASIO_NOEXCEPT + >::value + > = 0) noexcept : InnerExecutor(ex) { } @@ -90,25 +85,21 @@ class as_tuple_t /// Type alias to adapt an I/O object to use @c as_tuple_t as its /// default completion token type. -#if defined(ASIO_HAS_ALIAS_TEMPLATES) \ - || defined(GENERATING_DOCUMENTATION) template using as_default_on_t = typename T::template rebind_executor< - executor_with_default >::other; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - // || defined(GENERATING_DOCUMENTATION) + executor_with_default>::other; /// Function helper to adapt an I/O object to use @c as_tuple_t as its /// default completion token type. template - static typename decay::type::template rebind_executor< - executor_with_default::type::executor_type> + static typename decay_t::template rebind_executor< + executor_with_default::executor_type> >::other - as_default_on(ASIO_MOVE_ARG(T) object) + as_default_on(T&& object) { - return typename decay::type::template rebind_executor< - executor_with_default::type::executor_type> - >::other(ASIO_MOVE_CAST(T)(object)); + return typename decay_t::template rebind_executor< + executor_with_default::executor_type> + >::other(static_cast(object)); } //private: @@ -119,11 +110,11 @@ class as_tuple_t /// arguments should be combined into a single tuple argument. template ASIO_NODISCARD inline -ASIO_CONSTEXPR as_tuple_t::type> -as_tuple(ASIO_MOVE_ARG(CompletionToken) completion_token) +constexpr as_tuple_t> +as_tuple(CompletionToken&& completion_token) { - return as_tuple_t::type>( - ASIO_MOVE_CAST(CompletionToken)(completion_token)); + return as_tuple_t>( + static_cast(completion_token)); } } // namespace asio @@ -132,8 +123,4 @@ as_tuple(ASIO_MOVE_ARG(CompletionToken) completion_token) #include "asio/impl/as_tuple.hpp" -#endif // (defined(ASIO_HAS_STD_TUPLE) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // ASIO_AS_TUPLE_HPP diff --git a/third/asio/associated_allocator.hpp b/third/asio/associated_allocator.hpp index f4e978032..f21ea250e 100644 --- a/third/asio/associated_allocator.hpp +++ b/third/asio/associated_allocator.hpp @@ -2,7 +2,7 @@ // associated_allocator.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -36,9 +36,7 @@ struct has_allocator_type : false_type }; template -struct has_allocator_type::type> - : true_type +struct has_allocator_type> : true_type { }; @@ -49,33 +47,30 @@ struct associated_allocator_impl typedef A type; - static type get(const T&) ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const A& a) ASIO_NOEXCEPT + static const type& get(const T&, const A& a) noexcept { return a; } }; template -struct associated_allocator_impl::type> +struct associated_allocator_impl> { typedef typename T::allocator_type type; - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_allocator())) + static auto get(const T& t) noexcept + -> decltype(t.get_allocator()) { return t.get_allocator(); } - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const A&) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_allocator())) + static auto get(const T& t, const A&) noexcept + -> decltype(t.get_allocator()) { return t.get_allocator(); } @@ -83,12 +78,12 @@ struct associated_allocator_impl struct associated_allocator_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -115,7 +110,7 @@ struct associated_allocator_impl > +template > struct associated_allocator #if !defined(GENERATING_DOCUMENTATION) : detail::associated_allocator_impl @@ -128,11 +123,11 @@ struct associated_allocator /// If @c T has a nested type @c allocator_type, returns /// t.get_allocator(). Otherwise returns @c type(). - static decltype(auto) get(const T& t) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t) noexcept; /// If @c T has a nested type @c allocator_type, returns /// t.get_allocator(). Otherwise returns @c a. - static decltype(auto) get(const T& t, const Allocator& a) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t, const Allocator& a) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -142,7 +137,7 @@ struct associated_allocator */ template ASIO_NODISCARD inline typename associated_allocator::type -get_associated_allocator(const T& t) ASIO_NOEXCEPT +get_associated_allocator(const T& t) noexcept { return associated_allocator::get(t); } @@ -152,23 +147,17 @@ get_associated_allocator(const T& t) ASIO_NOEXCEPT * @returns associated_allocator::get(t, a) */ template -ASIO_NODISCARD inline ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_allocator::type) -get_associated_allocator(const T& t, const Allocator& a) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_allocator::get(t, a))) +ASIO_NODISCARD inline auto get_associated_allocator( + const T& t, const Allocator& a) noexcept + -> decltype(associated_allocator::get(t, a)) { return associated_allocator::get(t, a); } -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - -template > +template > using associated_allocator_t = typename associated_allocator::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -178,22 +167,19 @@ struct associated_allocator_forwarding_base template struct associated_allocator_forwarding_base::asio_associated_allocator_is_unspecialised, void >::value - >::type> + >> { typedef void asio_associated_allocator_is_unspecialised; }; } // namespace detail -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_allocator for @c std::reference_wrapper. template struct associated_allocator, Allocator> @@ -207,25 +193,20 @@ struct associated_allocator, Allocator> /// Forwards the request to get the allocator to the associator specialisation /// for the unwrapped type @c T. - static type get(reference_wrapper t) ASIO_NOEXCEPT + static type get(reference_wrapper t) noexcept { return associated_allocator::get(t.get()); } /// Forwards the request to get the allocator to the associator specialisation /// for the unwrapped type @c T. - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - reference_wrapper t, const Allocator& a) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_allocator::get(t.get(), a))) + static auto get(reference_wrapper t, const Allocator& a) noexcept + -> decltype(associated_allocator::get(t.get(), a)) { return associated_allocator::get(t.get(), a); } }; -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio #include "asio/detail/pop_options.hpp" diff --git a/third/asio/associated_cancellation_slot.hpp b/third/asio/associated_cancellation_slot.hpp index d5b802db8..518bd881e 100644 --- a/third/asio/associated_cancellation_slot.hpp +++ b/third/asio/associated_cancellation_slot.hpp @@ -2,7 +2,7 @@ // associated_cancellation_slot.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -36,9 +36,8 @@ struct has_cancellation_slot_type : false_type }; template -struct has_cancellation_slot_type::type> - : true_type +struct has_cancellation_slot_type> + : true_type { }; @@ -49,12 +48,12 @@ struct associated_cancellation_slot_impl typedef S type; - static type get(const T&) ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const S& s) ASIO_NOEXCEPT + static const type& get(const T&, const S& s) noexcept { return s; } @@ -62,20 +61,18 @@ struct associated_cancellation_slot_impl template struct associated_cancellation_slot_impl::type> + void_t> { typedef typename T::cancellation_slot_type type; - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_cancellation_slot())) + static auto get(const T& t) noexcept + -> decltype(t.get_cancellation_slot()) { return t.get_cancellation_slot(); } - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const S&) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_cancellation_slot())) + static auto get(const T& t, const S&) noexcept + -> decltype(t.get_cancellation_slot()) { return t.get_cancellation_slot(); } @@ -83,12 +80,12 @@ struct associated_cancellation_slot_impl struct associated_cancellation_slot_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -129,12 +126,12 @@ struct associated_cancellation_slot /// If @c T has a nested type @c cancellation_slot_type, returns /// t.get_cancellation_slot(). Otherwise returns @c type(). - static decltype(auto) get(const T& t) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t) noexcept; /// If @c T has a nested type @c cancellation_slot_type, returns /// t.get_cancellation_slot(). Otherwise returns @c s. static decltype(auto) get(const T& t, - const CancellationSlot& s) ASIO_NOEXCEPT; + const CancellationSlot& s) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -144,7 +141,7 @@ struct associated_cancellation_slot */ template ASIO_NODISCARD inline typename associated_cancellation_slot::type -get_associated_cancellation_slot(const T& t) ASIO_NOEXCEPT +get_associated_cancellation_slot(const T& t) noexcept { return associated_cancellation_slot::get(t); } @@ -155,24 +152,17 @@ get_associated_cancellation_slot(const T& t) ASIO_NOEXCEPT * CancellationSlot>::get(t, st) */ template -ASIO_NODISCARD inline ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_cancellation_slot::type) -get_associated_cancellation_slot(const T& t, - const CancellationSlot& st) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_cancellation_slot::get(t, st))) +ASIO_NODISCARD inline auto get_associated_cancellation_slot( + const T& t, const CancellationSlot& st) noexcept + -> decltype(associated_cancellation_slot::get(t, st)) { return associated_cancellation_slot::get(t, st); } -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - template using associated_cancellation_slot_t = typename associated_cancellation_slot::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -182,22 +172,19 @@ struct associated_cancellation_slot_forwarding_base template struct associated_cancellation_slot_forwarding_base::asio_associated_cancellation_slot_is_unspecialised, void >::value - >::type> + >> { typedef void asio_associated_cancellation_slot_is_unspecialised; }; } // namespace detail -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_cancellation_slot for @c /// std::reference_wrapper. template @@ -212,25 +199,21 @@ struct associated_cancellation_slot, CancellationSlot> /// Forwards the request to get the cancellation slot to the associator /// specialisation for the unwrapped type @c T. - static type get(reference_wrapper t) ASIO_NOEXCEPT + static type get(reference_wrapper t) noexcept { return associated_cancellation_slot::get(t.get()); } /// Forwards the request to get the cancellation slot to the associator /// specialisation for the unwrapped type @c T. - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get(reference_wrapper t, - const CancellationSlot& s = CancellationSlot()) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_cancellation_slot::get(t.get(), s))) + static auto get(reference_wrapper t, const CancellationSlot& s) noexcept + -> decltype( + associated_cancellation_slot::get(t.get(), s)) { return associated_cancellation_slot::get(t.get(), s); } }; -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio #include "asio/detail/pop_options.hpp" diff --git a/third/asio/associated_executor.hpp b/third/asio/associated_executor.hpp index b76c204e5..4ca7ba149 100644 --- a/third/asio/associated_executor.hpp +++ b/third/asio/associated_executor.hpp @@ -2,7 +2,7 @@ // associated_executor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -38,8 +38,7 @@ struct has_executor_type : false_type }; template -struct has_executor_type::type> +struct has_executor_type> : true_type { }; @@ -51,33 +50,30 @@ struct associated_executor_impl typedef E type; - static type get(const T&) ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const E& e) ASIO_NOEXCEPT + static const type& get(const T&, const E& e) noexcept { return e; } }; template -struct associated_executor_impl::type> +struct associated_executor_impl> { typedef typename T::executor_type type; - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_executor())) + static auto get(const T& t) noexcept + -> decltype(t.get_executor()) { return t.get_executor(); } - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const E&) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_executor())) + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_executor()) { return t.get_executor(); } @@ -85,12 +81,12 @@ struct associated_executor_impl struct associated_executor_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -130,11 +126,11 @@ struct associated_executor /// If @c T has a nested type @c executor_type, returns /// t.get_executor(). Otherwise returns @c type(). - static decltype(auto) get(const T& t) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t) noexcept; /// If @c T has a nested type @c executor_type, returns /// t.get_executor(). Otherwise returns @c ex. - static decltype(auto) get(const T& t, const Executor& ex) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t, const Executor& ex) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -144,7 +140,7 @@ struct associated_executor */ template ASIO_NODISCARD inline typename associated_executor::type -get_associated_executor(const T& t) ASIO_NOEXCEPT +get_associated_executor(const T& t) noexcept { return associated_executor::get(t); } @@ -154,14 +150,12 @@ get_associated_executor(const T& t) ASIO_NOEXCEPT * @returns associated_executor::get(t, ex) */ template -ASIO_NODISCARD inline ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_executor::type) -get_associated_executor(const T& t, const Executor& ex, - typename constraint< +ASIO_NODISCARD inline auto get_associated_executor( + const T& t, const Executor& ex, + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_executor::get(t, ex))) + > = 0) noexcept + -> decltype(associated_executor::get(t, ex)) { return associated_executor::get(t, ex); } @@ -172,27 +166,19 @@ get_associated_executor(const T& t, const Executor& ex, * ExecutionContext::executor_type>::get(t, ctx.get_executor()) */ template -ASIO_NODISCARD inline ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_executor::type) +ASIO_NODISCARD inline typename associated_executor::type get_associated_executor(const T& t, ExecutionContext& ctx, - typename constraint::value>::type = 0) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_executor::get(t, ctx.get_executor()))) + constraint_t::value> = 0) noexcept { return associated_executor::get(t, ctx.get_executor()); } -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - template using associated_executor_t = typename associated_executor::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -202,22 +188,19 @@ struct associated_executor_forwarding_base template struct associated_executor_forwarding_base::asio_associated_executor_is_unspecialised, void >::value - >::type> + >> { typedef void asio_associated_executor_is_unspecialised; }; } // namespace detail -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_executor for @c std::reference_wrapper. template struct associated_executor, Executor> @@ -231,25 +214,20 @@ struct associated_executor, Executor> /// Forwards the request to get the executor to the associator specialisation /// for the unwrapped type @c T. - static type get(reference_wrapper t) ASIO_NOEXCEPT + static type get(reference_wrapper t) noexcept { return associated_executor::get(t.get()); } /// Forwards the request to get the executor to the associator specialisation /// for the unwrapped type @c T. - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - reference_wrapper t, const Executor& ex) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_executor::get(t.get(), ex))) + static auto get(reference_wrapper t, const Executor& ex) noexcept + -> decltype(associated_executor::get(t.get(), ex)) { return associated_executor::get(t.get(), ex); } }; -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio #include "asio/detail/pop_options.hpp" diff --git a/third/asio/associated_immediate_executor.hpp b/third/asio/associated_immediate_executor.hpp new file mode 100644 index 000000000..aa6e0fcfe --- /dev/null +++ b/third/asio/associated_immediate_executor.hpp @@ -0,0 +1,280 @@ +// +// associated_immediate_executor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP +#define ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include "asio/detail/config.hpp" +#include "asio/associator.hpp" +#include "asio/detail/functional.hpp" +#include "asio/detail/type_traits.hpp" +#include "asio/execution/blocking.hpp" +#include "asio/execution/executor.hpp" +#include "asio/execution_context.hpp" +#include "asio/is_executor.hpp" +#include "asio/require.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { + +template +struct associated_immediate_executor; + +namespace detail { + +template +struct has_immediate_executor_type : false_type +{ +}; + +template +struct has_immediate_executor_type> + : true_type +{ +}; + +template +struct default_immediate_executor +{ + typedef require_result_t type; + + static type get(const E& e) noexcept + { + return asio::require(e, execution::blocking.never); + } +}; + +template +struct default_immediate_executor::value + >, + enable_if_t< + is_executor::value + >> +{ + class type : public E + { + public: + template + explicit type(const Executor1& e, + constraint_t< + conditional_t< + !is_same::value, + is_convertible, + false_type + >::value + > = 0) noexcept + : E(e) + { + } + + type(const type& other) noexcept + : E(static_cast(other)) + { + } + + type(type&& other) noexcept + : E(static_cast(other)) + { + } + + template + void dispatch(Function&& f, const Allocator& a) const + { + this->post(static_cast(f), a); + } + + friend bool operator==(const type& a, const type& b) noexcept + { + return static_cast(a) == static_cast(b); + } + + friend bool operator!=(const type& a, const type& b) noexcept + { + return static_cast(a) != static_cast(b); + } + }; + + static type get(const E& e) noexcept + { + return type(e); + } +}; + +template +struct associated_immediate_executor_impl +{ + typedef void asio_associated_immediate_executor_is_unspecialised; + + typedef typename default_immediate_executor::type type; + + static auto get(const T&, const E& e) noexcept + -> decltype(default_immediate_executor::get(e)) + { + return default_immediate_executor::get(e); + } +}; + +template +struct associated_immediate_executor_impl> +{ + typedef typename T::immediate_executor_type type; + + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_immediate_executor()) + { + return t.get_immediate_executor(); + } +}; + +template +struct associated_immediate_executor_impl::value + >, + void_t< + typename associator::type + >> : associator +{ +}; + +} // namespace detail + +/// Traits type used to obtain the immediate executor associated with an object. +/** + * A program may specialise this traits type if the @c T template parameter in + * the specialisation is a user-defined type. The template parameter @c + * Executor shall be a type meeting the Executor requirements. + * + * Specialisations shall meet the following requirements, where @c t is a const + * reference to an object of type @c T, and @c e is an object of type @c + * Executor. + * + * @li Provide a nested typedef @c type that identifies a type meeting the + * Executor requirements. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t) and with return type @c type or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,e) and with return type @c type or a (possibly const) reference to @c + * type. + */ +template +struct associated_immediate_executor +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_impl +#endif // !defined(GENERATING_DOCUMENTATION) +{ +#if defined(GENERATING_DOCUMENTATION) + /// If @c T has a nested type @c immediate_executor_type, + // T::immediate_executor_type. Otherwise @c Executor. + typedef see_below type; + + /// If @c T has a nested type @c immediate_executor_type, returns + /// t.get_immediate_executor(). Otherwise returns + /// asio::require(ex, asio::execution::blocking.never). + static decltype(auto) get(const T& t, const Executor& ex) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ex) + */ +template +ASIO_NODISCARD inline auto get_associated_immediate_executor( + const T& t, const Executor& ex, + constraint_t< + is_executor::value || execution::is_executor::value + > = 0) noexcept + -> decltype(associated_immediate_executor::get(t, ex)) +{ + return associated_immediate_executor::get(t, ex); +} + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ctx.get_executor()) + */ +template +ASIO_NODISCARD inline typename associated_immediate_executor::type +get_associated_immediate_executor(const T& t, ExecutionContext& ctx, + constraint_t< + is_convertible::value + > = 0) noexcept +{ + return associated_immediate_executor::get(t, ctx.get_executor()); +} + +template +using associated_immediate_executor_t = + typename associated_immediate_executor::type; + +namespace detail { + +template +struct associated_immediate_executor_forwarding_base +{ +}; + +template +struct associated_immediate_executor_forwarding_base::asio_associated_immediate_executor_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_immediate_executor_is_unspecialised; +}; + +} // namespace detail + +/// Specialisation of associated_immediate_executor for +/// @c std::reference_wrapper. +template +struct associated_immediate_executor, Executor> +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_forwarding_base +#endif // !defined(GENERATING_DOCUMENTATION) +{ + /// Forwards @c type to the associator specialisation for the unwrapped type + /// @c T. + typedef typename associated_immediate_executor::type type; + + /// Forwards the request to get the executor to the associator specialisation + /// for the unwrapped type @c T. + static auto get(reference_wrapper t, const Executor& ex) noexcept + -> decltype(associated_immediate_executor::get(t.get(), ex)) + { + return associated_immediate_executor::get(t.get(), ex); + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP diff --git a/third/asio/associator.hpp b/third/asio/associator.hpp index 1452de6a2..7952fcc51 100644 --- a/third/asio/associator.hpp +++ b/third/asio/associator.hpp @@ -2,7 +2,7 @@ // associator.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/third/asio/async_result.hpp b/third/asio/async_result.hpp index 47fde00f5..cdae9ede6 100644 --- a/third/asio/async_result.hpp +++ b/third/asio/async_result.hpp @@ -2,7 +2,7 @@ // async_result.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,15 +17,12 @@ #include "asio/detail/config.hpp" #include "asio/detail/type_traits.hpp" -#include "asio/detail/variadic_templates.hpp" #include "asio/detail/push_options.hpp" namespace asio { -#if defined(ASIO_HAS_CONCEPTS) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES) \ - && defined(ASIO_HAS_DECLTYPE) +#if defined(ASIO_HAS_CONCEPTS) namespace detail { @@ -39,8 +36,6 @@ struct is_completion_signature : true_type { }; -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct is_completion_signature : true_type { @@ -69,7 +64,6 @@ struct is_completion_signature : true_type }; # endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) template struct are_completion_signatures : false_type @@ -103,21 +97,19 @@ struct is_completion_handler_for : false_type template struct is_completion_handler_for - : integral_constant)> + : integral_constant, Args...>)> { }; -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct is_completion_handler_for - : integral_constant)> + : integral_constant&, Args...>)> { }; template struct is_completion_handler_for - : integral_constant)> + : integral_constant&&, Args...>)> { }; @@ -125,24 +117,23 @@ struct is_completion_handler_for template struct is_completion_handler_for - : integral_constant)> + : integral_constant, Args...>)> { }; template struct is_completion_handler_for - : integral_constant)> + : integral_constant&, Args...>)> { }; template struct is_completion_handler_for - : integral_constant)> + : integral_constant&&, Args...>)> { }; # endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) template struct is_completion_handler_for @@ -174,8 +165,6 @@ ASIO_CONCEPT completion_handler_for = ::asio::completion_handler_for #else // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(ASIO_HAS_DECLTYPE) #define ASIO_COMPLETION_SIGNATURE typename #define ASIO_COMPLETION_HANDLER_FOR(sig) typename @@ -183,277 +172,130 @@ ASIO_CONCEPT completion_handler_for = #define ASIO_COMPLETION_HANDLER_FOR3(sig0, sig1, sig2) typename #endif // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(ASIO_HAS_DECLTYPE) namespace detail { template -struct is_simple_completion_signature : false_type +struct is_lvalue_completion_signature : false_type { }; -template -struct simple_completion_signature; +template +struct is_lvalue_completion_signature : true_type +{ +}; -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) +# if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) template -struct is_simple_completion_signature : true_type +struct is_lvalue_completion_signature : true_type { }; +# endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) + template -struct are_simple_completion_signatures : false_type +struct are_any_lvalue_completion_signatures : false_type { }; template -struct are_simple_completion_signatures - : is_simple_completion_signature +struct are_any_lvalue_completion_signatures + : is_lvalue_completion_signature { }; template -struct are_simple_completion_signatures +struct are_any_lvalue_completion_signatures : integral_constant::value - && are_simple_completion_signatures::value)> -{ -}; - -template -struct simple_completion_signature + is_lvalue_completion_signature::value + || are_any_lvalue_completion_signatures::value)> { - typedef R type(Args...); }; -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -struct simple_completion_signature +template +struct is_rvalue_completion_signature : false_type { - typedef R type(Args...); }; template -struct simple_completion_signature +struct is_rvalue_completion_signature : true_type { - typedef R type(Args...); }; # if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) template -struct simple_completion_signature +struct is_rvalue_completion_signature : true_type { - typedef R type(Args...); -}; - -template -struct simple_completion_signature -{ - typedef R type(Args...); -}; - -template -struct simple_completion_signature -{ - typedef R type(Args...); }; # endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct is_simple_completion_signature : true_type -{ -}; - -#define ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct is_simple_completion_signature \ - : true_type \ - { \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef ASIO_PRIVATE_SIMPLE_SIG_DEF - -template -struct are_simple_completion_signatures : false_type +template +struct are_any_rvalue_completion_signatures : false_type { }; template -struct are_simple_completion_signatures - : is_simple_completion_signature +struct are_any_rvalue_completion_signatures + : is_rvalue_completion_signature { }; -template -struct are_simple_completion_signatures - : integral_constant::value - && is_simple_completion_signature::value)> -{ -}; - -template -struct are_simple_completion_signatures - : integral_constant::value - && is_simple_completion_signature::value - && is_simple_completion_signature::value)> +template +struct are_any_rvalue_completion_signatures + : integral_constant::value + || are_any_rvalue_completion_signatures::value)> { }; -template <> -struct simple_completion_signature -{ - typedef void type; -}; +template +struct simple_completion_signature; -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -#define ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef ASIO_PRIVATE_SIMPLE_SIG_DEF - -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -#define ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature< \ - R(ASIO_VARIADIC_TARGS(n)) &> \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(ASIO_VARIADIC_TARGS(n)) &&> \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef ASIO_PRIVATE_SIMPLE_SIG_DEF - # if defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -template -struct simple_completion_signature +template +struct simple_completion_signature { - typedef R type(); + typedef R type(Args...); }; -#define ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature< \ - R(ASIO_VARIADIC_TARGS(n)) noexcept> \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(ASIO_VARIADIC_TARGS(n)) & noexcept> \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(ASIO_VARIADIC_TARGS(n)) && noexcept> \ - { \ - typedef R type(ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef ASIO_PRIVATE_SIMPLE_SIG_DEF - # endif // defined(ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) \ - || defined(GENERATING_DOCUMENTATION) - -# define ASIO_COMPLETION_SIGNATURES_TPARAMS \ - ASIO_COMPLETION_SIGNATURE... Signatures - -# define ASIO_COMPLETION_SIGNATURES_TSPECPARAMS \ - ASIO_COMPLETION_SIGNATURE... Signatures - -# define ASIO_COMPLETION_SIGNATURES_TARGS Signatures... - -# define ASIO_COMPLETION_SIGNATURES_TSIMPLEARGS \ - typename asio::detail::simple_completion_signature< \ - Signatures>::type... - -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - // || defined(GENERATING_DOCUMENTATION) - -# define ASIO_COMPLETION_SIGNATURES_TPARAMS \ - typename Sig0 = void, \ - typename Sig1 = void, \ - typename Sig2 = void -# define ASIO_COMPLETION_SIGNATURES_TSPECPARAMS \ - typename Sig0, \ - typename Sig1, \ - typename Sig2 - -# define ASIO_COMPLETION_SIGNATURES_TARGS Sig0, Sig1, Sig2 - -# define ASIO_COMPLETION_SIGNATURES_TSIMPLEARGS \ - typename ::asio::detail::simple_completion_signature::type, \ - typename ::asio::detail::simple_completion_signature::type, \ - typename ::asio::detail::simple_completion_signature::type - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - // || defined(GENERATING_DOCUMENTATION) - -template +template class completion_handler_async_result { public: @@ -468,56 +310,22 @@ class completion_handler_async_result { } -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) - template - static return_type initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token, - ASIO_MOVE_ARG(Args)... args) + static return_type initiate(Initiation&& initiation, + RawCompletionToken&& token, Args&&... args) { - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(RawCompletionToken)(token), - ASIO_MOVE_CAST(Args)(args)...); + static_cast(initiation)( + static_cast(token), + static_cast(args)...); } -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - - template - static return_type initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token) - { - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(RawCompletionToken)(token)); - } - -#define ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - static return_type initiate( \ - ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_MOVE_ARG(RawCompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - ASIO_MOVE_CAST(Initiation)(initiation)( \ - ASIO_MOVE_CAST(RawCompletionToken)(token), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INITIATE_DEF) -#undef ASIO_PRIVATE_INITIATE_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - private: completion_handler_async_result( - const completion_handler_async_result&) ASIO_DELETED; + const completion_handler_async_result&) = delete; completion_handler_async_result& operator=( - const completion_handler_async_result&) ASIO_DELETED; + const completion_handler_async_result&) = delete; }; } // namespace detail @@ -542,7 +350,8 @@ class completion_handler_async_result * The primary template assumes that the CompletionToken is the completion * handler. */ -template +template class async_result { public: @@ -567,70 +376,46 @@ class async_result /// obtain the value to be returned from the initiating function. template static return_type initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token, - ASIO_MOVE_ARG(Args)... args); + Initiation&& initiation, + RawCompletionToken&& token, + Args&&... args); private: - async_result(const async_result&) ASIO_DELETED; - async_result& operator=(const async_result&) ASIO_DELETED; + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; }; #else // defined(GENERATING_DOCUMENTATION) -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template +template class async_result : - public conditional< - detail::are_simple_completion_signatures< - ASIO_COMPLETION_SIGNATURES_TARGS>::value, - detail::completion_handler_async_result< - CompletionToken, ASIO_COMPLETION_SIGNATURES_TARGS>, + public conditional_t< + detail::are_any_lvalue_completion_signatures::value + || !detail::are_any_rvalue_completion_signatures::value, + detail::completion_handler_async_result, async_result - >::type + typename detail::simple_completion_signature::type...> + > { public: - typedef typename conditional< - detail::are_simple_completion_signatures< - ASIO_COMPLETION_SIGNATURES_TARGS>::value, - detail::completion_handler_async_result< - CompletionToken, ASIO_COMPLETION_SIGNATURES_TARGS>, + typedef conditional_t< + detail::are_any_lvalue_completion_signatures::value + || !detail::are_any_rvalue_completion_signatures::value, + detail::completion_handler_async_result, async_result - >::type base_type; + typename detail::simple_completion_signature::type...> + > base_type; using base_type::base_type; private: - async_result(const async_result&) ASIO_DELETED; - async_result& operator=(const async_result&) ASIO_DELETED; + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; }; -#else // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -class async_result : - public detail::completion_handler_async_result< - CompletionToken, ASIO_COMPLETION_SIGNATURES_TARGS> -{ -public: - explicit async_result(CompletionToken& h) - : detail::completion_handler_async_result< - CompletionToken, ASIO_COMPLETION_SIGNATURES_TARGS>(h) - { - } - -private: - async_result(const async_result&) ASIO_DELETED; - async_result& operator=(const async_result&) ASIO_DELETED; -}; - -#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -class async_result +template +class async_result { // Empty. }; @@ -640,65 +425,39 @@ class async_result /// Helper template to deduce the handler type from a CompletionToken, capture /// a local copy of the handler, and then create an async_result for the /// handler. -template +template struct async_completion { /// The real handler type to be used for the asynchronous operation. typedef typename asio::async_result< - typename decay::type, - ASIO_COMPLETION_SIGNATURES_TARGS>::completion_handler_type - completion_handler_type; + decay_t, Signatures...>::completion_handler_type + completion_handler_type; -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Constructor. /** * The constructor creates the concrete completion handler and makes the link * between the handler and the asynchronous result. */ explicit async_completion(CompletionToken& token) - : completion_handler(static_cast::value, - completion_handler_type&, CompletionToken&&>::type>(token)), - result(completion_handler) - { - } -#else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - explicit async_completion(typename decay::type& token) - : completion_handler(token), + completion_handler_type&, CompletionToken&&>>(token)), result(completion_handler) { } - explicit async_completion(const typename decay::type& token) - : completion_handler(token), - result(completion_handler) - { - } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// A copy of, or reference to, a real handler object. -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - typename conditional< + conditional_t< is_same::value, - completion_handler_type&, completion_handler_type>::type completion_handler; -#else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - completion_handler_type completion_handler; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + completion_handler_type&, completion_handler_type> completion_handler; /// The result of the asynchronous operation's initiating function. - async_result::type, - ASIO_COMPLETION_SIGNATURES_TARGS> result; + async_result, Signatures...> result; }; namespace detail { -template -struct async_result_helper - : async_result::type, - ASIO_COMPLETION_SIGNATURES_TARGS> -{ -}; - struct async_result_memfns_base { void initiate(); @@ -724,11 +483,11 @@ char async_result_initiate_memfn_helper( void (async_result_memfns_base::*)(), &async_result_memfns_derived::initiate>*); -template +template struct async_result_has_initiate_memfn : integral_constant::type, - ASIO_COMPLETION_SIGNATURES_TARGS> + async_result, Signatures...> >(0)) != 1> { }; @@ -742,25 +501,6 @@ struct async_result_has_initiate_memfn void_or_deduced # define ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \ void_or_deduced -#elif defined(_MSC_VER) && (_MSC_VER < 1500) -# define ASIO_INITFN_RESULT_TYPE(ct, sig) \ - typename ::asio::detail::async_result_helper< \ - ct, sig>::return_type -# define ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) \ - typename ::asio::detail::async_result_helper< \ - ct, sig0, sig1>::return_type -# define ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \ - typename ::asio::detail::async_result_helper< \ - ct, sig0, sig1, sig2>::return_type -#define ASIO_HANDLER_TYPE(ct, sig) \ - typename ::asio::detail::async_result_helper< \ - ct, sig>::completion_handler_type -#define ASIO_HANDLER_TYPE2(ct, sig0, sig1) \ - typename ::asio::detail::async_result_helper< \ - ct, sig0, sig1>::completion_handler_type -#define ASIO_HANDLER_TYPE3(ct, sig0, sig1, sig2) \ - typename ::asio::detail::async_result_helper< \ - ct, sig0, sig1, sig2>::completion_handler_type #else # define ASIO_INITFN_RESULT_TYPE(ct, sig) \ typename ::asio::async_result< \ @@ -823,7 +563,7 @@ struct async_result_has_initiate_memfn # define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ auto # define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) -#elif defined(ASIO_HAS_DECLTYPE) +#else # define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \ auto # define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \ @@ -831,14 +571,6 @@ struct async_result_has_initiate_memfn # define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ auto # define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) -> decltype expr -#else -# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \ - ASIO_INITFN_RESULT_TYPE(ct, sig) -# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \ - ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) -# define ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ - ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) -# define ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) #endif #if defined(GENERATING_DOCUMENTATION) @@ -848,20 +580,13 @@ struct async_result_has_initiate_memfn void_or_deduced # define ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ void_or_deduced -#elif defined(ASIO_HAS_DECLTYPE) +#else # define ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \ decltype expr # define ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \ decltype expr # define ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ decltype expr -#else -# define ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \ - ASIO_INITFN_RESULT_TYPE(ct, sig) -# define ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \ - ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) -# define ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ - ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) #endif #if defined(GENERATING_DOCUMENTATION) @@ -870,326 +595,57 @@ template void_or_deduced async_initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken), - ASIO_MOVE_ARG(Args)... args); + Initiation&& initiation, + type_identity_t& token, + Args&&... args); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) +#else // defined(GENERATING_DOCUMENTATION) template -inline typename constraint< +inline auto async_initiate(Initiation&& initiation, + type_identity_t& token, Args&&... args) + -> constraint_t< detail::async_result_has_initiate_memfn< CompletionToken, Signatures...>::value, - ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, Signatures..., - (async_result::type, - Signatures...>::initiate(declval(), - declval(), - declval()...)))>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, - ASIO_MOVE_ARG(Args)... args) -{ - return async_result::type, - Signatures...>::initiate(ASIO_MOVE_CAST(Initiation)(initiation), - ASIO_MOVE_CAST(CompletionToken)(token), - ASIO_MOVE_CAST(Args)(args)...); + decltype( + async_result, Signatures...>::initiate( + static_cast(initiation), + static_cast(token), + static_cast(args)...))> +{ + return async_result, Signatures...>::initiate( + static_cast(initiation), + static_cast(token), + static_cast(args)...); } template -inline typename constraint< +inline constraint_t< !detail::async_result_has_initiate_memfn< CompletionToken, Signatures...>::value, - ASIO_INITFN_RESULT_TYPE(CompletionToken, Signatures...)>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, - ASIO_MOVE_ARG(Args)... args) + typename async_result, Signatures...>::return_type> +async_initiate(Initiation&& initiation, + type_identity_t& token, Args&&... args) { async_completion completion(token); - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(CompletionToken, - Signatures...))(completion.completion_handler), - ASIO_MOVE_CAST(Args)(args)...); - - return completion.result.get(); -} - -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0>::value, - ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, Sig0, - (async_result::type, - Sig0>::initiate(declval(), - declval())))>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0>::initiate(ASIO_MOVE_CAST(Initiation)(initiation), - ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1>::value, - ASIO_INITFN_DEDUCED_RESULT_TYPE2(CompletionToken, Sig0, Sig1, - (async_result::type, - Sig0, Sig1>::initiate(declval(), - declval())))>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0, Sig1>::initiate(ASIO_MOVE_CAST(Initiation)(initiation), - ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1, Sig2>::value, - ASIO_INITFN_DEDUCED_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2, - (async_result::type, - Sig0, Sig1, Sig2>::initiate(declval(), - declval())))>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0, Sig1, Sig2>::initiate(ASIO_MOVE_CAST(Initiation)(initiation), - ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - !detail::async_result_has_initiate_memfn< - CompletionToken, Sig0>::value, - ASIO_INITFN_RESULT_TYPE(CompletionToken, Sig0)>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(CompletionToken, - Sig0))(completion.completion_handler)); + static_cast(initiation)( + static_cast< + typename async_result, + Signatures...>::completion_handler_type&&>( + completion.completion_handler), + static_cast(args)...); return completion.result.get(); } -template -inline typename constraint< - !detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1>::value, - ASIO_INITFN_RESULT_TYPE2(CompletionToken, Sig0, Sig1)>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE2(CompletionToken, - Sig0, Sig1))(completion.completion_handler)); - - return completion.result.get(); -} - -template -inline typename constraint< - !detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1, Sig2>::value, - ASIO_INITFN_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2)>::type -async_initiate(ASIO_MOVE_ARG(Initiation) initiation, - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE3(CompletionToken, - Sig0, Sig1, Sig2))(completion.completion_handler)); - - return completion.result.get(); -} +#endif // defined(GENERATING_DOCUMENTATION) -#define ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0>::value, \ - ASIO_INITFN_DEDUCED_RESULT_TYPE( \ - CompletionToken, Sig0, \ - (async_result::type, \ - Sig0>::initiate( \ - declval(), \ - declval(), \ - ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0>::initiate( \ - ASIO_MOVE_CAST(Initiation)(initiation), \ - ASIO_MOVE_CAST(CompletionToken)(token), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1>::value, \ - ASIO_INITFN_DEDUCED_RESULT_TYPE2( \ - CompletionToken, Sig0, Sig1, \ - (async_result::type, \ - Sig0, Sig1>::initiate( \ - declval(), \ - declval(), \ - ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0, Sig1>::initiate( \ - ASIO_MOVE_CAST(Initiation)(initiation), \ - ASIO_MOVE_CAST(CompletionToken)(token), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1, Sig2>::value, \ - ASIO_INITFN_DEDUCED_RESULT_TYPE3( \ - CompletionToken, Sig0, Sig1, Sig2, \ - (async_result::type, \ - Sig0, Sig1, Sig2>::initiate( \ - declval(), \ - declval(), \ - ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0, Sig1, Sig2>::initiate( \ - ASIO_MOVE_CAST(Initiation)(initiation), \ - ASIO_MOVE_CAST(CompletionToken)(token), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0>::value, \ - ASIO_INITFN_RESULT_TYPE(CompletionToken, Sig0)>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - ASIO_MOVE_CAST(Initiation)(initiation)( \ - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(CompletionToken, \ - Sig0))(completion.completion_handler), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1>::value, \ - ASIO_INITFN_RESULT_TYPE2(CompletionToken, Sig0, Sig1)>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - ASIO_MOVE_CAST(Initiation)(initiation)( \ - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE2(CompletionToken, \ - Sig0, Sig1))(completion.completion_handler), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1, Sig2>::value, \ - ASIO_INITFN_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2)>::type \ - async_initiate(ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - ASIO_MOVE_CAST(Initiation)(initiation)( \ - ASIO_MOVE_CAST(ASIO_HANDLER_TYPE3(CompletionToken, \ - Sig0, Sig1, Sig2))(completion.completion_handler), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INITIATE_DEF) -#undef ASIO_PRIVATE_INITIATE_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -#if defined(ASIO_HAS_CONCEPTS) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES) \ - && defined(ASIO_HAS_DECLTYPE) +#if defined(ASIO_HAS_CONCEPTS) namespace detail { @@ -1222,16 +678,12 @@ ASIO_CONCEPT completion_token_for = ::asio::completion_token_for #else // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(ASIO_HAS_DECLTYPE) #define ASIO_COMPLETION_TOKEN_FOR(sig) typename #define ASIO_COMPLETION_TOKEN_FOR2(sig0, sig1) typename #define ASIO_COMPLETION_TOKEN_FOR3(sig0, sig1, sig2) typename #endif // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(ASIO_HAS_DECLTYPE) namespace detail { @@ -1245,21 +697,21 @@ struct is_async_operation_call : false_type template struct is_async_operation_call::type, + result_of_t, async_operation_probe_result >::value - >::type - >::type> : true_type + > + > + > : true_type { }; } // namespace detail #if !defined(GENERATING_DOCUMENTATION) -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) template class async_result @@ -1268,59 +720,16 @@ class async_result typedef detail::async_operation_probe_result return_type; template - static return_type initiate(ASIO_MOVE_ARG(Initiation), - detail::async_operation_probe, ASIO_MOVE_ARG(InitArgs)...) + static return_type initiate(Initiation&&, + detail::async_operation_probe, InitArgs&&...) { return return_type(); } }; -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -namespace detail { - -struct async_result_probe_base -{ - typedef detail::async_operation_probe_result return_type; - - template - static return_type initiate(ASIO_MOVE_ARG(Initiation), - detail::async_operation_probe) - { - return return_type(); - } - -#define ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - static return_type initiate(ASIO_MOVE_ARG(Initiation), \ - detail::async_operation_probe, \ - ASIO_VARIADIC_UNNAMED_MOVE_PARAMS(n)) \ - { \ - return return_type(); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INITIATE_DEF) -#undef ASIO_PRIVATE_INITIATE_DEF -}; - -} // namespace detail - -template -class async_result - : public detail::async_result_probe_base {}; - -template -class async_result - : public detail::async_result_probe_base {}; - -template -class async_result - : public detail::async_result_probe_base {}; - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) #endif // !defined(GENERATING_DOCUMENTATION) -#if defined(GENERATION_DOCUMENTATION) +#if defined(GENERATING_DOCUMENTATION) /// The is_async_operation trait detects whether a type @c T and arguments /// @c Args... may be used to initiate an asynchronous operation. @@ -1335,7 +744,7 @@ struct is_async_operation : integral_constant { }; -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) +#else // defined(GENERATING_DOCUMENTATION) template struct is_async_operation : @@ -1344,32 +753,9 @@ struct is_async_operation : { }; -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct is_async_operation : - detail::is_async_operation_call< - T(detail::async_operation_probe)> -{ -}; - -#define ASIO_PRIVATE_IS_ASYNC_OP_DEF(n) \ - template \ - struct is_async_operation : \ - detail::is_async_operation_call< \ - T(ASIO_VARIADIC_TARGS(n), detail::async_operation_probe)> \ - { \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_IS_ASYNC_OP_DEF) -#undef ASIO_PRIVATE_IS_ASYNC_OP_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) +#endif // defined(GENERATING_DOCUMENTATION) -#if defined(ASIO_HAS_CONCEPTS) \ - && defined(ASIO_HAS_VARIADIC_TEMPLATES) +#if defined(ASIO_HAS_CONCEPTS) template ASIO_CONCEPT async_operation = is_async_operation::value; @@ -1384,7 +770,6 @@ ASIO_CONCEPT async_operation = is_async_operation::value; ::asio::async_operation #else // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) #define ASIO_ASYNC_OPERATION(t) typename #define ASIO_ASYNC_OPERATION1(t, a0) typename @@ -1392,37 +777,56 @@ ASIO_CONCEPT async_operation = is_async_operation::value; #define ASIO_ASYNC_OPERATION3(t, a0, a1, a2) typename #endif // defined(ASIO_HAS_CONCEPTS) - // && defined(ASIO_HAS_VARIADIC_TEMPLATES) namespace detail { struct completion_signature_probe {}; -template +template struct completion_signature_probe_result +{ + template