diff --git a/.appveyor.yml b/.appveyor.yml index db7b09b3fa..d5c8b8c5e4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,7 +1,6 @@ version: "{branch} (#{build})" image: - - Visual Studio 2013 - Visual Studio 2015 - Visual Studio 2017 - Visual Studio 2019 @@ -39,18 +38,6 @@ environment: MINGW: 1 for: - - - matrix: - only: - - image: Visual Studio 2013 - environment: - BOOSTDIR: C:\Libraries\boost_1_58_0 - build_script: - - call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86 - - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 - - cd asio\src - - nmake -f Makefile.msc - - nmake -f Makefile.msc check - matrix: only: @@ -103,14 +90,6 @@ for: matrix: exclude: - - image: Visual Studio 2013 - SEPARATE_COMPILATION: 1 - - image: Visual Studio 2013 - CXXLATEST: 1 - - image: Visual Studio 2013 - USING_BOOST: 1 - - image: Visual Studio 2013 - MINGW: 1 - image: Visual Studio 2015 HEADER_ONLY: 1 - image: Visual Studio 2015 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acda82acf1..1f784e87de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: build-type: ['sanity'] runs-on: [ubuntu-20.04, ubuntu-22.04, macos-latest] compiler: [g++-7, g++-8, g++-9, g++-10, g++-11, g++-12, clang++-10, clang++-14, g++] - cxx-std: ['c++03', 'c++11', 'c++14', 'c++17', 'c++2a', 'c++20'] + cxx-std: ['c++11', 'c++14', 'c++17', 'c++2a', 'c++20'] separate-compilation: ['', '--enable-separate-compilation'] optim-level: ['-O0'] no-deprecated: [''] @@ -111,8 +111,6 @@ jobs: select-reactor: -DASIO_DISABLE_EPOLL - compiler: g++-11 select-reactor: -DASIO_DISABLE_EPOLL - # C++03 builds are always explicitly included - - cxx-std: c++03 include: # # Linux / g++-12 -std=c++20 -fcoroutines / -O2 / standalone @@ -237,17 +235,6 @@ jobs: separate-compilation: --enable-separate-compilation optim-level: -O0 # - # Linux / g++-7 / -O2 / boost 1.80 - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: g++-7 - cxx-std: c++03 - separate-compilation: --enable-separate-compilation - optim-level: -O2 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # # Linux / g++-7 -std=c++11 / -O2 / boost 1.80 # - build-type: full @@ -284,17 +271,6 @@ jobs: cxx-std: c++11 optim-level: -O2 # - # Linux / clang++-10 -std=c++11 / -O0 / boost 1.80 / separate compilation - # - - build-type: full - runs-on: ubuntu-20.04 - compiler: clang++-10 - cxx-std: c++03 - separate-compilation: --enable-separate-compilation - optim-level: -O0 - with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 - boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 - # # macOS / c++2a -fcoroutines-ts / -O2 / standalone # - build-type: full @@ -329,22 +305,22 @@ jobs: separate-compilation: --enable-separate-compilation optim-level: -O0 # - # macOS / c++03 / -O2 / boost 1.80 + # macOS / c++11 / -O2 / boost 1.80 # - build-type: full runs-on: macos-latest compiler: g++ - cxx-std: c++03 + cxx-std: c++11 optim-level: -O2 with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 boost-url: https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 # - # macOS / c++03 / -O2 / boost 1.80 / separate compilation + # macOS / c++11 / -O2 / boost 1.80 / separate compilation # - build-type: full runs-on: macos-latest compiler: g++ - cxx-std: c++03 + cxx-std: c++11 separate-compilation: --enable-separate-compilation optim-level: -O0 with-boost: --with-boost=$GITHUB_WORKSPACE/boost_1_80_0 diff --git a/asio/include/Makefile.am b/asio/include/Makefile.am index d7a9b9c608..e97a1515f4 100644 --- a/asio/include/Makefile.am +++ b/asio/include/Makefile.am @@ -100,10 +100,6 @@ nobase_include_HEADERS = \ asio/detail/fenced_block.hpp \ asio/detail/functional.hpp \ asio/detail/future.hpp \ - asio/detail/gcc_arm_fenced_block.hpp \ - asio/detail/gcc_hppa_fenced_block.hpp \ - asio/detail/gcc_sync_fenced_block.hpp \ - asio/detail/gcc_x86_fenced_block.hpp \ asio/detail/global.hpp \ asio/detail/handler_alloc_helpers.hpp \ asio/detail/handler_cont_helpers.hpp \ @@ -199,7 +195,6 @@ nobase_include_HEADERS = \ asio/detail/kqueue_reactor.hpp \ asio/detail/limits.hpp \ asio/detail/local_free_on_block_exit.hpp \ - asio/detail/macos_fenced_block.hpp \ asio/detail/memory.hpp \ asio/detail/mutex.hpp \ asio/detail/non_const_lvalue.hpp \ @@ -271,7 +266,6 @@ nobase_include_HEADERS = \ asio/detail/socket_option.hpp \ asio/detail/socket_select_interrupter.hpp \ asio/detail/socket_types.hpp \ - asio/detail/solaris_fenced_block.hpp \ asio/detail/source_location.hpp \ asio/detail/static_mutex.hpp \ asio/detail/std_event.hpp \ @@ -298,14 +292,12 @@ nobase_include_HEADERS = \ asio/detail/tss_ptr.hpp \ asio/detail/type_traits.hpp \ asio/detail/utility.hpp \ - asio/detail/variadic_templates.hpp \ asio/detail/wait_handler.hpp \ asio/detail/wait_op.hpp \ asio/detail/winapp_thread.hpp \ asio/detail/wince_thread.hpp \ asio/detail/win_event.hpp \ asio/detail/win_fd_set_adapter.hpp \ - asio/detail/win_fenced_block.hpp \ asio/detail/win_global.hpp \ asio/detail/win_iocp_file_service.hpp \ asio/detail/win_iocp_handle_read_op.hpp \ diff --git a/asio/include/asio/any_completion_executor.hpp b/asio/include/asio/any_completion_executor.hpp index 420927cc1d..92798ab5d7 100644 --- a/asio/include/asio/any_completion_executor.hpp +++ b/asio/include/asio/any_completion_executor.hpp @@ -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/asio/include/asio/any_completion_handler.hpp b/asio/include/asio/any_completion_handler.hpp index 32d6bfe926..dc61d4d90e 100644 --- a/asio/include/asio/any_completion_handler.hpp +++ b/asio/include/asio/any_completion_handler.hpp @@ -12,12 +12,6 @@ #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 @@ -41,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(); } @@ -61,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)) { } @@ -105,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; @@ -121,14 +115,14 @@ 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 ASIO_NOEXCEPT + const any_io_executor& candidate) const noexcept { return any_completion_executor(std::nothrow, (get_associated_immediate_executor)(handler_, candidate)); @@ -189,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: @@ -216,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: @@ -475,7 +469,7 @@ 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_) { @@ -497,7 +491,7 @@ class 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_) { @@ -505,14 +499,14 @@ class any_completion_handler_allocator /// 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_; } @@ -549,7 +543,7 @@ 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_) { @@ -571,7 +565,7 @@ class 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_) { @@ -579,14 +573,14 @@ class any_completion_handler_allocator /// 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_; } @@ -651,16 +645,16 @@ class any_completion_handler } /// Construct an @c any_completion_handler to contain the specified target. - template ::type> + template > any_completion_handler(H&& h, - typename constraint< - !is_same::type, any_completion_handler>::value - >::type = 0) + 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))) { } @@ -668,7 +662,7 @@ class any_completion_handler /** * After the operation, the moved-from object @c other has no target. */ - any_completion_handler(any_completion_handler&& other) ASIO_NOEXCEPT + any_completion_handler(any_completion_handler&& other) noexcept : fn_table_(other.fn_table_), impl_(other.impl_) { @@ -681,15 +675,15 @@ class any_completion_handler * 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( - ASIO_MOVE_CAST(any_completion_handler)(other)).swap(*this); + static_cast(other)).swap(*this); return *this; } /// Assignment operator that sets the polymorphic wrapper to the empty state. - any_completion_handler& operator=(nullptr_t) ASIO_NOEXCEPT + any_completion_handler& operator=(nullptr_t) noexcept { any_completion_handler().swap(*this); return *this; @@ -703,32 +697,32 @@ class any_completion_handler } /// Test if the polymorphic wrapper is empty. - constexpr explicit operator bool() const ASIO_NOEXCEPT + constexpr explicit operator bool() const noexcept { return impl_ != nullptr; } /// Test if the polymorphic wrapper is non-empty. - constexpr bool operator!() const ASIO_NOEXCEPT + constexpr bool operator!() const noexcept { return impl_ == nullptr; } /// Swap the content of an @c any_completion_handler with another. - void swap(any_completion_handler& other) ASIO_NOEXCEPT + void swap(any_completion_handler& other) noexcept { std::swap(fn_table_, other.fn_table_); std::swap(impl_, other.impl_); } /// Get the associated allocator. - allocator_type get_allocator() const ASIO_NOEXCEPT + allocator_type get_allocator() const noexcept { return allocator_type(0, *this); } /// Get the associated cancellation slot. - cancellation_slot_type get_cancellation_slot() const ASIO_NOEXCEPT + cancellation_slot_type get_cancellation_slot() const noexcept { return impl_->get_cancellation_slot(); } @@ -744,12 +738,12 @@ class any_completion_handler */ 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); @@ -757,28 +751,28 @@ class any_completion_handler /// 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_; } @@ -790,7 +784,7 @@ 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)); @@ -804,7 +798,7 @@ struct associated_immediate_executor< 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_->immediate_executor(handler.impl_, any_io_executor(std::nothrow, candidate)); @@ -815,9 +809,4 @@ struct associated_immediate_executor< #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/asio/include/asio/any_io_executor.hpp b/asio/include/asio/any_io_executor.hpp index 7a77c90d12..2abe882778 100644 --- a/asio/include/asio/any_io_executor.hpp +++ b/asio/include/asio/any_io_executor.hpp @@ -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/asio/include/asio/append.hpp b/asio/include/asio/append.hpp index 9ac4a95044..e8fcd72470 100644 --- a/asio/include/asio/append.hpp +++ b/asio/include/asio/append.hpp @@ -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/asio/include/asio/as_tuple.hpp b/asio/include/asio/as_tuple.hpp index 96ac47c82e..35e746e464 100644 --- a/asio/include/asio/as_tuple.hpp +++ b/asio/include/asio/as_tuple.hpp @@ -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/asio/include/asio/associated_allocator.hpp b/asio/include/asio/associated_allocator.hpp index 8e864673cd..31b95ba1a3 100644 --- a/asio/include/asio/associated_allocator.hpp +++ b/asio/include/asio/associated_allocator.hpp @@ -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/asio/include/asio/associated_cancellation_slot.hpp b/asio/include/asio/associated_cancellation_slot.hpp index 65d82b646b..69f969e5f4 100644 --- a/asio/include/asio/associated_cancellation_slot.hpp +++ b/asio/include/asio/associated_cancellation_slot.hpp @@ -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) 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/asio/include/asio/associated_executor.hpp b/asio/include/asio/associated_executor.hpp index 92279891d6..4b949dc051 100644 --- a/asio/include/asio/associated_executor.hpp +++ b/asio/include/asio/associated_executor.hpp @@ -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); } @@ -175,20 +169,16 @@ template ASIO_NODISCARD inline typename associated_executor::type get_associated_executor(const T& t, ExecutionContext& ctx, - typename constraint::value>::type = 0) ASIO_NOEXCEPT + 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 @@ -198,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> @@ -227,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/asio/include/asio/associated_immediate_executor.hpp b/asio/include/asio/associated_immediate_executor.hpp index 54bced17a5..4c2b3f8bfa 100644 --- a/asio/include/asio/associated_immediate_executor.hpp +++ b/asio/include/asio/associated_immediate_executor.hpp @@ -41,7 +41,7 @@ struct has_immediate_executor_type : false_type template struct has_immediate_executor_type::type> + void_t> : true_type { }; @@ -49,9 +49,9 @@ struct has_immediate_executor_type struct default_immediate_executor { - typedef typename require_result::type type; + typedef require_result_t type; - static type get(const E& e) ASIO_NOEXCEPT + static type get(const E& e) noexcept { return asio::require(e, execution::blocking.never); } @@ -59,59 +59,57 @@ struct default_immediate_executor template struct default_immediate_executor::value - >::type, - typename enable_if< + >, + enable_if_t< is_executor::value - >::type> + >> { class type : public E { public: template explicit type(const Executor1& e, - typename constraint< - conditional< + constraint_t< + conditional_t< !is_same::value, is_convertible, false_type - >::type::value - >::type = 0) ASIO_NOEXCEPT + >::value + > = 0) noexcept : E(e) { } - type(const type& other) ASIO_NOEXCEPT + type(const type& other) noexcept : E(static_cast(other)) { } -#if defined(ASIO_HAS_MOVE) - type(type&& other) ASIO_NOEXCEPT - : E(ASIO_MOVE_CAST(E)(other)) + type(type&& other) noexcept + : E(static_cast(other)) { } -#endif // defined(ASIO_HAS_MOVE) template - void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a) const + void dispatch(Function&& f, const Allocator& a) const { - this->post(ASIO_MOVE_CAST(Function)(f), a); + this->post(static_cast(f), a); } - friend bool operator==(const type& a, const type& b) ASIO_NOEXCEPT + 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) ASIO_NOEXCEPT + friend bool operator!=(const type& a, const type& b) noexcept { return static_cast(a) != static_cast(b); } }; - static type get(const E& e) ASIO_NOEXCEPT + static type get(const E& e) noexcept { return type(e); } @@ -124,9 +122,8 @@ struct associated_immediate_executor_impl typedef typename default_immediate_executor::type type; - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T&, const E& e) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((default_immediate_executor::get(e))) + static auto get(const T&, const E& e) noexcept + -> decltype(default_immediate_executor::get(e)) { return default_immediate_executor::get(e); } @@ -134,13 +131,12 @@ struct associated_immediate_executor_impl template struct associated_immediate_executor_impl::type> + void_t> { typedef typename T::immediate_executor_type type; - static ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const E&) ASIO_NOEXCEPT - ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_immediate_executor())) + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_immediate_executor()) { return t.get_immediate_executor(); } @@ -148,12 +144,12 @@ struct associated_immediate_executor_impl struct associated_immediate_executor_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -194,7 +190,7 @@ struct associated_immediate_executor /// 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) ASIO_NOEXCEPT; + static decltype(auto) get(const T& t, const Executor& ex) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -203,14 +199,12 @@ struct associated_immediate_executor * @returns associated_immediate_executor::get(t, ex) */ template -ASIO_NODISCARD inline ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_immediate_executor::type) -get_associated_immediate_executor(const T& t, const Executor& ex, - typename constraint< +ASIO_NODISCARD inline auto get_associated_immediate_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_immediate_executor::get(t, ex))) + > = 0) noexcept + -> decltype(associated_immediate_executor::get(t, ex)) { return associated_immediate_executor::get(t, ex); } @@ -224,21 +218,18 @@ template ASIO_NODISCARD inline typename associated_immediate_executor::type get_associated_immediate_executor(const T& t, ExecutionContext& ctx, - typename constraint::value>::type = 0) ASIO_NOEXCEPT + constraint_t< + is_convertible::value + > = 0) noexcept { return associated_immediate_executor::get(t, ctx.get_executor()); } -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - template using associated_immediate_executor_t = typename associated_immediate_executor::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -248,22 +239,19 @@ struct associated_immediate_executor_forwarding_base template struct associated_immediate_executor_forwarding_base::asio_associated_immediate_executor_is_unspecialised, void >::value - >::type> + >> { typedef void asio_associated_immediate_executor_is_unspecialised; }; } // namespace detail -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_immediate_executor for /// @c std::reference_wrapper. template @@ -278,18 +266,13 @@ struct associated_immediate_executor, Executor> /// 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_immediate_executor::get(t.get(), ex))) + 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); } }; -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio #include "asio/detail/pop_options.hpp" diff --git a/asio/include/asio/async_result.hpp b/asio/include/asio/async_result.hpp index a7f97b0a33..11a803256c 100644 --- a/asio/include/asio/async_result.hpp +++ b/asio/include/asio/async_result.hpp @@ -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 @@ -107,8 +101,6 @@ struct is_completion_handler_for { }; -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct is_completion_handler_for : integral_constant)> @@ -142,7 +134,6 @@ struct is_completion_handler_for }; # 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,8 +172,6 @@ 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 { @@ -196,8 +183,6 @@ struct is_simple_completion_signature : false_type template struct simple_completion_signature; -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) - template struct is_simple_completion_signature : true_type { @@ -228,8 +213,6 @@ struct simple_completion_signature typedef R type(Args...); }; -#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct simple_completion_signature { @@ -263,197 +246,9 @@ struct simple_completion_signature }; # 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_simple_completion_signatures - : is_simple_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 simple_completion_signature -{ - typedef void type; -}; - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -#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 -{ - typedef R type(); -}; - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -#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 -{ - typedef R type(); -}; - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -#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 +263,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) - { - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(RawCompletionToken)(token), - ASIO_MOVE_CAST(Args)(args)...); - } - -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - - template - static return_type initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token) + static return_type initiate(Initiation&& initiation, + RawCompletionToken&& token, Args&&... args) { - ASIO_MOVE_CAST(Initiation)(initiation)( - ASIO_MOVE_CAST(RawCompletionToken)(token)); + static_cast(initiation)( + static_cast(token), + static_cast(args)...); } -#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 +303,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 +329,44 @@ 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_simple_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_simple_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 +376,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 +434,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 +452,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 +514,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 +522,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 +531,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 +546,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 +629,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 +648,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,56 +671,13 @@ 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(GENERATING_DOCUMENTATION) @@ -1335,7 +695,7 @@ struct is_async_operation : integral_constant { }; -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) +#else // defined(GENERATING_DOCUMENTATION) template struct is_async_operation : @@ -1344,35 +704,9 @@ struct is_async_operation : { }; -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct is_async_operation; - -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; @@ -1387,7 +721,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 @@ -1395,14 +728,11 @@ 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 {}; -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) - template struct completion_signature_probe_result { @@ -1435,25 +765,9 @@ struct completion_signature_probe_result }; }; -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct completion_signature_probe_result -{ - typedef T type; -}; - -template <> -struct completion_signature_probe_result -{ -}; - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - } // namespace detail #if !defined(GENERATING_DOCUMENTATION) -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) template class async_result @@ -1462,8 +776,8 @@ class async_result typedef detail::completion_signature_probe_result return_type; template - static return_type initiate(ASIO_MOVE_ARG(Initiation), - detail::completion_signature_probe, ASIO_MOVE_ARG(InitArgs)...) + static return_type initiate(Initiation&&, + detail::completion_signature_probe, InitArgs&&...) { return return_type(); } @@ -1476,62 +790,13 @@ class async_result typedef detail::completion_signature_probe_result return_type; template - static return_type initiate(ASIO_MOVE_ARG(Initiation), - detail::completion_signature_probe, ASIO_MOVE_ARG(InitArgs)...) + static return_type initiate(Initiation&&, + detail::completion_signature_probe, InitArgs&&...) { return return_type(); } }; -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -namespace detail { - -template -class async_result_sig_probe_base -{ -public: - typedef detail::completion_signature_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::completion_signature_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_sig_probe_base {}; - -template -class async_result - : public detail::async_result_sig_probe_base {}; - -template -class async_result - : public detail::async_result_sig_probe_base {}; - -template -class async_result - : public detail::async_result_sig_probe_base {}; - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) #endif // !defined(GENERATING_DOCUMENTATION) #if defined(GENERATING_DOCUMENTATION) @@ -1554,50 +819,19 @@ struct completion_signature_of typedef automatically_determined type; }; -template -using completion_signature_of_t = - typename completion_signature_of::type; - -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) +#else // defined(GENERATING_DOCUMENTATION) template struct completion_signature_of : - result_of::type + result_of_t { }; -#if defined(ASIO_HAS_ALIAS_TEMPLATES) +#endif // defined(GENERATING_DOCUMENTATION) + template using completion_signature_of_t = typename completion_signature_of::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct completion_signature_of; - -template -struct completion_signature_of : - result_of::type -{ -}; - -#define ASIO_PRIVATE_COMPLETION_SIG_OF_DEF(n) \ - template \ - struct completion_signature_of : \ - result_of< \ - T(ASIO_VARIADIC_TARGS(n), \ - detail::completion_signature_probe)>::type \ - { \ - }; \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_COMPLETION_SIG_OF_DEF) -#undef ASIO_PRIVATE_COMPLETION_SIG_OF_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) namespace detail { @@ -1609,7 +843,8 @@ struct default_completion_token_impl template struct default_completion_token_impl::type> + void_t + > { typedef typename T::default_completion_token_type type; }; @@ -1643,27 +878,14 @@ struct default_completion_token }; #endif -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - template using default_completion_token_t = typename default_completion_token::type; -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - -#if defined(ASIO_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS) - #define ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(e) \ = typename ::asio::default_completion_token::type #define ASIO_DEFAULT_COMPLETION_TOKEN(e) \ = typename ::asio::default_completion_token::type() -#else // defined(ASIO_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS) - -#define ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(e) -#define ASIO_DEFAULT_COMPLETION_TOKEN(e) - -#endif // defined(ASIO_HAS_DEFAULT_FUNCTION_TEMPLATE_ARGUMENTS) - } // namespace asio #include "asio/detail/pop_options.hpp" diff --git a/asio/include/asio/basic_datagram_socket.hpp b/asio/include/asio/basic_datagram_socket.hpp index 2ec611b996..3c0ead3bf6 100644 --- a/asio/include/asio/basic_datagram_socket.hpp +++ b/asio/include/asio/basic_datagram_socket.hpp @@ -113,9 +113,9 @@ class basic_datagram_socket */ template explicit basic_datagram_socket(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context) { } @@ -151,10 +151,10 @@ class basic_datagram_socket template basic_datagram_socket(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_socket(context, protocol) { } @@ -198,9 +198,9 @@ class basic_datagram_socket template basic_datagram_socket(ExecutionContext& context, const endpoint_type& endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, endpoint) { } @@ -243,14 +243,13 @@ class basic_datagram_socket template basic_datagram_socket(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_socket, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, protocol, native_socket) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_datagram_socket from another. /** * This constructor moves a datagram socket from one object to another. @@ -262,7 +261,7 @@ class basic_datagram_socket * constructed using the @c basic_datagram_socket(const executor_type&) * constructor. */ - basic_datagram_socket(basic_datagram_socket&& other) ASIO_NOEXCEPT + basic_datagram_socket(basic_datagram_socket&& other) noexcept : basic_socket(std::move(other)) { } @@ -299,10 +298,10 @@ class basic_datagram_socket */ template basic_datagram_socket(basic_datagram_socket&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : basic_socket(std::move(other)) { } @@ -321,16 +320,15 @@ class basic_datagram_socket * constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_datagram_socket& - >::type operator=(basic_datagram_socket&& other) + > operator=(basic_datagram_socket&& other) { basic_socket::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the socket. /** @@ -479,18 +477,14 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -544,18 +538,14 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -705,19 +695,15 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send_to(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, buffers, - destination, socket_base::message_flags(0)))) + destination, socket_base::message_flags(0))) { return async_initiate( @@ -770,19 +756,15 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send_to(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, destination, flags))) + buffers, destination, flags)) { return async_initiate( @@ -933,18 +915,14 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -998,18 +976,14 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -1159,19 +1133,15 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive_from(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, buffers, - &sender_endpoint, socket_base::message_flags(0)))) + &sender_endpoint, socket_base::message_flags(0))) { return async_initiate( @@ -1226,19 +1196,15 @@ class basic_datagram_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive_from(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, &sender_endpoint, flags))) + buffers, &sender_endpoint, flags)) { return async_initiate( @@ -1248,9 +1214,9 @@ class basic_datagram_socket private: // Disallow copying and assignment. - basic_datagram_socket(const basic_datagram_socket&) ASIO_DELETED; + basic_datagram_socket(const basic_datagram_socket&) = delete; basic_datagram_socket& operator=( - const basic_datagram_socket&) ASIO_DELETED; + const basic_datagram_socket&) = delete; class initiate_async_send { @@ -1262,13 +1228,13 @@ class basic_datagram_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, socket_base::message_flags flags) const { @@ -1296,13 +1262,13 @@ class basic_datagram_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags) const { @@ -1330,13 +1296,13 @@ class basic_datagram_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, socket_base::message_flags flags) const { @@ -1364,13 +1330,13 @@ class basic_datagram_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, endpoint_type* sender_endpoint, socket_base::message_flags flags) const { diff --git a/asio/include/asio/basic_deadline_timer.hpp b/asio/include/asio/basic_deadline_timer.hpp index d0d44d0e5a..795e844323 100644 --- a/asio/include/asio/basic_deadline_timer.hpp +++ b/asio/include/asio/basic_deadline_timer.hpp @@ -178,9 +178,9 @@ class basic_deadline_timer */ template explicit basic_deadline_timer(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { } @@ -216,9 +216,9 @@ class basic_deadline_timer */ template basic_deadline_timer(ExecutionContext& context, const time_type& expiry_time, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -260,9 +260,9 @@ class basic_deadline_timer template basic_deadline_timer(ExecutionContext& context, const duration_type& expiry_time, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -271,7 +271,6 @@ class basic_deadline_timer asio::detail::throw_error(ec, "expires_from_now"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_deadline_timer from another. /** * This constructor moves a timer from one object to another. @@ -305,7 +304,6 @@ class basic_deadline_timer impl_ = std::move(other.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the timer. /** @@ -317,7 +315,7 @@ class basic_deadline_timer } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -649,15 +647,12 @@ class basic_deadline_timer */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code)) - WaitToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WaitToken, - void (asio::error_code)) - async_wait( - ASIO_MOVE_ARG(WaitToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WaitToken = default_completion_token_t> + auto async_wait( + WaitToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token))) + declval(), token)) { return async_initiate( initiate_async_wait(this), token); @@ -665,9 +660,9 @@ class basic_deadline_timer private: // Disallow copying and assignment. - basic_deadline_timer(const basic_deadline_timer&) ASIO_DELETED; + basic_deadline_timer(const basic_deadline_timer&) = delete; basic_deadline_timer& operator=( - const basic_deadline_timer&) ASIO_DELETED; + const basic_deadline_timer&) = delete; class initiate_async_wait { @@ -679,13 +674,13 @@ class basic_deadline_timer { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WaitHandler) handler) const + void operator()(WaitHandler&& handler) const { // If you get an error on the following line it means that your handler // does not meet the documented type requirements for a WaitHandler. diff --git a/asio/include/asio/basic_file.hpp b/asio/include/asio/basic_file.hpp index eb690ac795..1a54a5a87a 100644 --- a/asio/include/asio/basic_file.hpp +++ b/asio/include/asio/basic_file.hpp @@ -21,6 +21,7 @@ || defined(GENERATING_DOCUMENTATION) #include +#include #include "asio/any_io_executor.hpp" #include "asio/async_result.hpp" #include "asio/detail/cstdint.hpp" @@ -39,10 +40,6 @@ # include "asio/detail/io_uring_file_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -112,10 +109,10 @@ class basic_file */ template explicit basic_file(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { } @@ -157,10 +154,10 @@ class basic_file template explicit basic_file(ExecutionContext& context, const char* path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -206,10 +203,10 @@ class basic_file template explicit basic_file(ExecutionContext& context, const std::string& path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -252,10 +249,10 @@ class basic_file */ template basic_file(ExecutionContext& context, const native_handle_type& native_file, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -264,7 +261,6 @@ class basic_file asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_file from another. /** * This constructor moves a file from one object to another. @@ -275,7 +271,7 @@ class basic_file * @note Following the move, the moved-from object is in the same state as if * constructed using the @c basic_file(const executor_type&) constructor. */ - basic_file(basic_file&& other) ASIO_NOEXCEPT + basic_file(basic_file&& other) noexcept : impl_(std::move(other.impl_)) { } @@ -312,10 +308,10 @@ class basic_file */ template basic_file(basic_file&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(std::move(other.impl_)) { } @@ -331,19 +327,18 @@ class basic_file * constructed using the @c basic_file(const executor_type&) constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_file& - >::type operator=(basic_file&& other) + > operator=(basic_file&& other) { basic_file tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -815,8 +810,8 @@ class basic_file private: // Disallow copying and assignment. - basic_file(const basic_file&) ASIO_DELETED; - basic_file& operator=(const basic_file&) ASIO_DELETED; + basic_file(const basic_file&) = delete; + basic_file& operator=(const basic_file&) = delete; }; } // namespace asio diff --git a/asio/include/asio/basic_io_object.hpp b/asio/include/asio/basic_io_object.hpp index 6d16a2b77b..b35b5fea71 100644 --- a/asio/include/asio/basic_io_object.hpp +++ b/asio/include/asio/basic_io_object.hpp @@ -22,7 +22,6 @@ namespace asio { -#if defined(ASIO_HAS_MOVE) namespace detail { // Type trait used to determine whether a service supports move. @@ -45,14 +44,13 @@ namespace detail static_cast(0))) == 1; }; } -#endif // defined(ASIO_HAS_MOVE) /// Base class for all I/O objects. /** * @note All I/O objects are non-copyable. However, when using C++0x, certain * I/O objects do support move construction and move assignment. */ -#if !defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) +#if defined(GENERATING_DOCUMENTATION) template #else template class basic_io_object @@ -213,7 +210,7 @@ class basic_io_object typedef asio::io_context::executor_type executor_type; - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return service_->get_io_context().get_executor(); } @@ -281,7 +278,6 @@ class basic_io_object IoObjectService* service_; implementation_type implementation_; }; -#endif // defined(ASIO_HAS_MOVE) } // namespace asio diff --git a/asio/include/asio/basic_random_access_file.hpp b/asio/include/asio/basic_random_access_file.hpp index ed5b231e43..57814d5aa5 100644 --- a/asio/include/asio/basic_random_access_file.hpp +++ b/asio/include/asio/basic_random_access_file.hpp @@ -107,10 +107,10 @@ class basic_random_access_file */ template explicit basic_random_access_file(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context) { } @@ -153,10 +153,10 @@ class basic_random_access_file template basic_random_access_file(ExecutionContext& context, const char* path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context, path, open_flags) { } @@ -199,10 +199,10 @@ class basic_random_access_file template basic_random_access_file(ExecutionContext& context, const std::string& path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context, path, open_flags) { } @@ -241,15 +241,14 @@ class basic_random_access_file template basic_random_access_file(ExecutionContext& context, const native_handle_type& native_file, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context, native_file) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_random_access_file from another. /** * This constructor moves a random-access file from one object to another. @@ -261,7 +260,7 @@ class basic_random_access_file * constructed using the @c basic_random_access_file(const executor_type&) * constructor. */ - basic_random_access_file(basic_random_access_file&& other) ASIO_NOEXCEPT + basic_random_access_file(basic_random_access_file&& other) noexcept : basic_file(std::move(other)) { } @@ -298,10 +297,10 @@ class basic_random_access_file */ template basic_random_access_file(basic_random_access_file&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(std::move(other)) { } @@ -320,15 +319,14 @@ class basic_random_access_file * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_random_access_file& - >::type operator=(basic_random_access_file&& other) + > operator=(basic_random_access_file&& other) { basic_file::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the file. /** @@ -459,18 +457,13 @@ class basic_random_access_file */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_write_some_at(uint64_t offset, - const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_write_some_at(uint64_t offset, const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, offset, buffers))) + declval(), token, offset, buffers)) { return async_initiate( @@ -600,18 +593,13 @@ class basic_random_access_file */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_read_some_at(uint64_t offset, - const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_read_some_at(uint64_t offset, const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, offset, buffers))) + declval(), token, offset, buffers)) { return async_initiate( @@ -620,9 +608,9 @@ class basic_random_access_file private: // Disallow copying and assignment. - basic_random_access_file(const basic_random_access_file&) ASIO_DELETED; + basic_random_access_file(const basic_random_access_file&) = delete; basic_random_access_file& operator=( - const basic_random_access_file&) ASIO_DELETED; + const basic_random_access_file&) = delete; class initiate_async_write_some_at { @@ -634,13 +622,13 @@ class basic_random_access_file { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, uint64_t offset, const ConstBufferSequence& buffers) const { // If you get an error on the following line it means that your handler @@ -667,13 +655,13 @@ class basic_random_access_file { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, uint64_t offset, const MutableBufferSequence& buffers) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/basic_raw_socket.hpp b/asio/include/asio/basic_raw_socket.hpp index 50583e5975..f35286acaf 100644 --- a/asio/include/asio/basic_raw_socket.hpp +++ b/asio/include/asio/basic_raw_socket.hpp @@ -113,9 +113,9 @@ class basic_raw_socket */ template explicit basic_raw_socket(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context) { } @@ -150,10 +150,10 @@ class basic_raw_socket */ template basic_raw_socket(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_socket(context, protocol) { } @@ -196,9 +196,9 @@ class basic_raw_socket */ template basic_raw_socket(ExecutionContext& context, const endpoint_type& endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, endpoint) { } @@ -241,14 +241,13 @@ class basic_raw_socket template basic_raw_socket(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_socket, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, protocol, native_socket) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_raw_socket from another. /** * This constructor moves a raw socket from one object to another. @@ -260,7 +259,7 @@ class basic_raw_socket * constructed using the @c basic_raw_socket(const executor_type&) * constructor. */ - basic_raw_socket(basic_raw_socket&& other) ASIO_NOEXCEPT + basic_raw_socket(basic_raw_socket&& other) noexcept : basic_socket(std::move(other)) { } @@ -296,10 +295,10 @@ class basic_raw_socket */ template basic_raw_socket(basic_raw_socket&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : basic_socket(std::move(other)) { } @@ -316,16 +315,15 @@ class basic_raw_socket * constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_raw_socket& - >::type operator=(basic_raw_socket&& other) + > operator=(basic_raw_socket&& other) { basic_socket::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the socket. /** @@ -471,18 +469,14 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -536,18 +530,14 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -697,19 +687,15 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send_to(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, buffers, - destination, socket_base::message_flags(0)))) + destination, socket_base::message_flags(0))) { return async_initiate( @@ -762,19 +748,15 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send_to(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, destination, flags))) + buffers, destination, flags)) { return async_initiate( @@ -925,18 +907,14 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -991,17 +969,14 @@ class basic_raw_socket template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, + = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -1151,19 +1126,16 @@ class basic_raw_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive_from(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token + = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, buffers, - &sender_endpoint, socket_base::message_flags(0)))) + &sender_endpoint, socket_base::message_flags(0))) { return async_initiate( @@ -1219,18 +1191,15 @@ class basic_raw_socket template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive_from(const MutableBufferSequence& buffers, + = default_completion_token_t> + auto async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, &sender_endpoint, flags))) + buffers, &sender_endpoint, flags)) { return async_initiate( @@ -1240,8 +1209,8 @@ class basic_raw_socket private: // Disallow copying and assignment. - basic_raw_socket(const basic_raw_socket&) ASIO_DELETED; - basic_raw_socket& operator=(const basic_raw_socket&) ASIO_DELETED; + basic_raw_socket(const basic_raw_socket&) = delete; + basic_raw_socket& operator=(const basic_raw_socket&) = delete; class initiate_async_send { @@ -1253,13 +1222,13 @@ class basic_raw_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, socket_base::message_flags flags) const { @@ -1287,13 +1256,13 @@ class basic_raw_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags) const { @@ -1321,13 +1290,13 @@ class basic_raw_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, socket_base::message_flags flags) const { @@ -1355,13 +1324,13 @@ class basic_raw_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, endpoint_type* sender_endpoint, socket_base::message_flags flags) const { diff --git a/asio/include/asio/basic_readable_pipe.hpp b/asio/include/asio/basic_readable_pipe.hpp index b774e1c22e..6f24de24c4 100644 --- a/asio/include/asio/basic_readable_pipe.hpp +++ b/asio/include/asio/basic_readable_pipe.hpp @@ -21,6 +21,7 @@ || defined(GENERATING_DOCUMENTATION) #include +#include #include "asio/any_io_executor.hpp" #include "asio/async_result.hpp" #include "asio/detail/handler_type_requirements.hpp" @@ -38,10 +39,6 @@ # include "asio/detail/reactive_descriptor_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -112,10 +109,10 @@ class basic_readable_pipe */ template explicit basic_readable_pipe(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { } @@ -159,9 +156,9 @@ class basic_readable_pipe template basic_readable_pipe(ExecutionContext& context, const native_handle_type& native_pipe, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -170,7 +167,6 @@ class basic_readable_pipe asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_readable_pipe from another. /** * This constructor moves a pipe from one object to another. @@ -221,10 +217,10 @@ class basic_readable_pipe */ template basic_readable_pipe(basic_readable_pipe&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(std::move(other.impl_)) { } @@ -241,16 +237,15 @@ class basic_readable_pipe * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_readable_pipe& - >::type operator=(basic_readable_pipe&& other) + > operator=(basic_readable_pipe&& other) { basic_readable_pipe tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the pipe. /** @@ -263,7 +258,7 @@ class basic_readable_pipe } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -561,17 +556,13 @@ class basic_readable_pipe */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_read_some(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_read_some(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -580,8 +571,8 @@ class basic_readable_pipe private: // Disallow copying and assignment. - basic_readable_pipe(const basic_readable_pipe&) ASIO_DELETED; - basic_readable_pipe& operator=(const basic_readable_pipe&) ASIO_DELETED; + basic_readable_pipe(const basic_readable_pipe&) = delete; + basic_readable_pipe& operator=(const basic_readable_pipe&) = delete; class initiate_async_read_some { @@ -593,13 +584,13 @@ class basic_readable_pipe { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/basic_seq_packet_socket.hpp b/asio/include/asio/basic_seq_packet_socket.hpp index b81ab88acc..e5b1ac11c2 100644 --- a/asio/include/asio/basic_seq_packet_socket.hpp +++ b/asio/include/asio/basic_seq_packet_socket.hpp @@ -111,9 +111,9 @@ class basic_seq_packet_socket */ template explicit basic_seq_packet_socket(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context) { } @@ -154,10 +154,10 @@ class basic_seq_packet_socket template basic_seq_packet_socket(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_socket(context, protocol) { } @@ -202,9 +202,9 @@ class basic_seq_packet_socket template basic_seq_packet_socket(ExecutionContext& context, const endpoint_type& endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, endpoint) { } @@ -247,14 +247,13 @@ class basic_seq_packet_socket template basic_seq_packet_socket(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_socket, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, protocol, native_socket) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_seq_packet_socket from another. /** * This constructor moves a sequenced packet socket from one object to @@ -267,7 +266,7 @@ class basic_seq_packet_socket * constructed using the @c basic_seq_packet_socket(const executor_type&) * constructor. */ - basic_seq_packet_socket(basic_seq_packet_socket&& other) ASIO_NOEXCEPT + basic_seq_packet_socket(basic_seq_packet_socket&& other) noexcept : basic_socket(std::move(other)) { } @@ -305,10 +304,10 @@ class basic_seq_packet_socket */ template basic_seq_packet_socket(basic_seq_packet_socket&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : basic_socket(std::move(other)) { } @@ -327,16 +326,15 @@ class basic_seq_packet_socket * constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_seq_packet_socket& - >::type operator=(basic_seq_packet_socket&& other) + > operator=(basic_seq_packet_socket&& other) { basic_socket::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the socket. /** @@ -459,17 +457,15 @@ class basic_seq_packet_socket template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, + = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token + = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -651,19 +647,15 @@ class basic_seq_packet_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, socket_base::message_flags& out_flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0), &out_flags))) + buffers, socket_base::message_flags(0), &out_flags)) { return async_initiate( @@ -731,20 +723,16 @@ class basic_seq_packet_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, socket_base::message_flags in_flags, socket_base::message_flags& out_flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), - token, buffers, in_flags, &out_flags))) + token, buffers, in_flags, &out_flags)) { return async_initiate( @@ -754,9 +742,9 @@ class basic_seq_packet_socket private: // Disallow copying and assignment. - basic_seq_packet_socket(const basic_seq_packet_socket&) ASIO_DELETED; + basic_seq_packet_socket(const basic_seq_packet_socket&) = delete; basic_seq_packet_socket& operator=( - const basic_seq_packet_socket&) ASIO_DELETED; + const basic_seq_packet_socket&) = delete; class initiate_async_send { @@ -768,13 +756,13 @@ class basic_seq_packet_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, socket_base::message_flags flags) const { @@ -802,13 +790,13 @@ class basic_seq_packet_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, socket_base::message_flags in_flags, socket_base::message_flags* out_flags) const diff --git a/asio/include/asio/basic_serial_port.hpp b/asio/include/asio/basic_serial_port.hpp index 59d5d363d0..a2f2013c51 100644 --- a/asio/include/asio/basic_serial_port.hpp +++ b/asio/include/asio/basic_serial_port.hpp @@ -22,6 +22,7 @@ || defined(GENERATING_DOCUMENTATION) #include +#include #include "asio/any_io_executor.hpp" #include "asio/async_result.hpp" #include "asio/detail/handler_type_requirements.hpp" @@ -38,10 +39,6 @@ # include "asio/detail/posix_serial_port_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -112,10 +109,10 @@ class basic_serial_port */ template explicit basic_serial_port(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { } @@ -154,9 +151,9 @@ class basic_serial_port */ template basic_serial_port(ExecutionContext& context, const char* device, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -198,9 +195,9 @@ class basic_serial_port */ template basic_serial_port(ExecutionContext& context, const std::string& device, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -247,9 +244,9 @@ class basic_serial_port template basic_serial_port(ExecutionContext& context, const native_handle_type& native_serial_port, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -258,7 +255,6 @@ class basic_serial_port asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_serial_port from another. /** * This constructor moves a serial port from one object to another. @@ -310,10 +306,10 @@ class basic_serial_port */ template basic_serial_port(basic_serial_port&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(std::move(other.impl_)) { } @@ -331,16 +327,15 @@ class basic_serial_port * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_serial_port& - >::type operator=(basic_serial_port&& other) + > operator=(basic_serial_port&& other) { basic_serial_port tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the serial port. /** @@ -353,7 +348,7 @@ class basic_serial_port } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -760,17 +755,13 @@ class basic_serial_port */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_write_some(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_write_some(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -895,17 +886,13 @@ class basic_serial_port */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_read_some(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_read_some(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -914,8 +901,8 @@ class basic_serial_port private: // Disallow copying and assignment. - basic_serial_port(const basic_serial_port&) ASIO_DELETED; - basic_serial_port& operator=(const basic_serial_port&) ASIO_DELETED; + basic_serial_port(const basic_serial_port&) = delete; + basic_serial_port& operator=(const basic_serial_port&) = delete; class initiate_async_write_some { @@ -927,13 +914,13 @@ class basic_serial_port { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers) const { // If you get an error on the following line it means that your handler @@ -960,13 +947,13 @@ class basic_serial_port { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/basic_signal_set.hpp b/asio/include/asio/basic_signal_set.hpp index cf70f13502..2eff5c65bf 100644 --- a/asio/include/asio/basic_signal_set.hpp +++ b/asio/include/asio/basic_signal_set.hpp @@ -134,10 +134,10 @@ class basic_signal_set : public signal_set_base */ template explicit basic_signal_set(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { } @@ -180,10 +180,10 @@ class basic_signal_set : public signal_set_base */ template basic_signal_set(ExecutionContext& context, int signal_number_1, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -239,10 +239,10 @@ class basic_signal_set : public signal_set_base template basic_signal_set(ExecutionContext& context, int signal_number_1, int signal_number_2, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -308,10 +308,10 @@ class basic_signal_set : public signal_set_base template basic_signal_set(ExecutionContext& context, int signal_number_1, int signal_number_2, int signal_number_3, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -334,7 +334,7 @@ class basic_signal_set : public signal_set_base } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -590,15 +590,12 @@ class basic_signal_set : public signal_set_base */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code, int)) - SignalToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(SignalToken, - void (asio::error_code, int)) - async_wait( - ASIO_MOVE_ARG(SignalToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + SignalToken = default_completion_token_t> + auto async_wait( + SignalToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token))) + declval(), token)) { return async_initiate( initiate_async_wait(this), token); @@ -606,8 +603,8 @@ class basic_signal_set : public signal_set_base private: // Disallow copying and assignment. - basic_signal_set(const basic_signal_set&) ASIO_DELETED; - basic_signal_set& operator=(const basic_signal_set&) ASIO_DELETED; + basic_signal_set(const basic_signal_set&) = delete; + basic_signal_set& operator=(const basic_signal_set&) = delete; class initiate_async_wait { @@ -619,13 +616,13 @@ class basic_signal_set : public signal_set_base { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(SignalHandler) handler) const + void operator()(SignalHandler&& handler) const { // If you get an error on the following line it means that your handler // does not meet the documented type requirements for a SignalHandler. diff --git a/asio/include/asio/basic_socket.hpp b/asio/include/asio/basic_socket.hpp index b2c8e499b1..5843084850 100644 --- a/asio/include/asio/basic_socket.hpp +++ b/asio/include/asio/basic_socket.hpp @@ -15,6 +15,7 @@ # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) +#include #include "asio/any_io_executor.hpp" #include "asio/detail/config.hpp" #include "asio/async_result.hpp" @@ -38,10 +39,6 @@ # include "asio/detail/reactive_socket_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -134,9 +131,9 @@ class basic_socket */ template explicit basic_socket(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { } @@ -174,10 +171,10 @@ class basic_socket */ template basic_socket(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -229,9 +226,9 @@ class basic_socket */ template basic_socket(ExecutionContext& context, const endpoint_type& endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -282,9 +279,9 @@ class basic_socket template basic_socket(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_socket, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -293,7 +290,6 @@ class basic_socket asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_socket from another. /** * This constructor moves a socket from one object to another. @@ -304,7 +300,7 @@ class basic_socket * @note Following the move, the moved-from object is in the same state as if * constructed using the @c basic_socket(const executor_type&) constructor. */ - basic_socket(basic_socket&& other) ASIO_NOEXCEPT + basic_socket(basic_socket&& other) noexcept : impl_(std::move(other.impl_)) { } @@ -341,10 +337,10 @@ class basic_socket */ template basic_socket(basic_socket&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : impl_(std::move(other.impl_)) { } @@ -360,20 +356,19 @@ class basic_socket * constructed using the @c basic_socket(const executor_type&) constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_socket& - >::type operator=(basic_socket&& other) + > operator=(basic_socket&& other) { basic_socket tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -967,16 +962,13 @@ class basic_socket */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code)) - ConnectToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ConnectToken, - void (asio::error_code)) - async_connect(const endpoint_type& peer_endpoint, - ASIO_MOVE_ARG(ConnectToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ConnectToken = default_completion_token_t> + auto async_connect(const endpoint_type& peer_endpoint, + ConnectToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, - peer_endpoint, declval()))) + declval(), token, + peer_endpoint, declval())) { asio::error_code open_ec; if (!is_open()) @@ -1821,15 +1813,12 @@ class basic_socket */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code)) - WaitToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WaitToken, - void (asio::error_code)) - async_wait(wait_type w, - ASIO_MOVE_ARG(WaitToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WaitToken = default_completion_token_t> + auto async_wait(wait_type w, + WaitToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, w))) + declval(), token, w)) { return async_initiate( initiate_async_wait(this), token, w); @@ -1861,8 +1850,8 @@ class basic_socket private: // Disallow copying and assignment. - basic_socket(const basic_socket&) ASIO_DELETED; - basic_socket& operator=(const basic_socket&) ASIO_DELETED; + basic_socket(const basic_socket&) = delete; + basic_socket& operator=(const basic_socket&) = delete; class initiate_async_connect { @@ -1874,13 +1863,13 @@ class basic_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ConnectHandler) handler, + void operator()(ConnectHandler&& handler, const endpoint_type& peer_endpoint, const asio::error_code& open_ec) const { @@ -1892,7 +1881,7 @@ class basic_socket { asio::post(self_->impl_.get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(ConnectHandler)(handler), open_ec)); + static_cast(handler), open_ec)); } else { @@ -1917,13 +1906,13 @@ class basic_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WaitHandler) handler, wait_type w) const + void operator()(WaitHandler&& handler, wait_type w) const { // If you get an error on the following line it means that your handler // does not meet the documented type requirements for a WaitHandler. diff --git a/asio/include/asio/basic_socket_acceptor.hpp b/asio/include/asio/basic_socket_acceptor.hpp index f0f7ed017a..f5ae339826 100644 --- a/asio/include/asio/basic_socket_acceptor.hpp +++ b/asio/include/asio/basic_socket_acceptor.hpp @@ -15,6 +15,7 @@ # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) +#include #include "asio/detail/config.hpp" #include "asio/any_io_executor.hpp" #include "asio/basic_socket.hpp" @@ -37,10 +38,6 @@ # include "asio/detail/reactive_socket_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -151,9 +148,9 @@ class basic_socket_acceptor */ template explicit basic_socket_acceptor(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { } @@ -193,10 +190,10 @@ class basic_socket_acceptor template basic_socket_acceptor(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { asio::error_code ec; @@ -282,9 +279,9 @@ class basic_socket_acceptor template basic_socket_acceptor(ExecutionContext& context, const endpoint_type& endpoint, bool reuse_addr = true, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -347,9 +344,9 @@ class basic_socket_acceptor template basic_socket_acceptor(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_acceptor, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -358,7 +355,6 @@ class basic_socket_acceptor asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_socket_acceptor from another. /** * This constructor moves an acceptor from one object to another. @@ -370,7 +366,7 @@ class basic_socket_acceptor * constructed using the @c basic_socket_acceptor(const executor_type&) * constructor. */ - basic_socket_acceptor(basic_socket_acceptor&& other) ASIO_NOEXCEPT + basic_socket_acceptor(basic_socket_acceptor&& other) noexcept : impl_(std::move(other.impl_)) { } @@ -410,10 +406,10 @@ class basic_socket_acceptor */ template basic_socket_acceptor(basic_socket_acceptor&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : impl_(std::move(other.impl_)) { } @@ -431,17 +427,16 @@ class basic_socket_acceptor * constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_socket_acceptor& - >::type operator=(basic_socket_acceptor&& other) + > operator=(basic_socket_acceptor&& other) { basic_socket_acceptor tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the acceptor. /** @@ -454,7 +449,7 @@ class basic_socket_acceptor } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -1254,15 +1249,12 @@ class basic_socket_acceptor */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code)) - WaitToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WaitToken, - void (asio::error_code)) - async_wait(wait_type w, - ASIO_MOVE_ARG(WaitToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WaitToken = default_completion_token_t> + auto async_wait(wait_type w, + WaitToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, w))) + declval(), token, w)) { return async_initiate( initiate_async_wait(this), token, w); @@ -1289,9 +1281,9 @@ class basic_socket_acceptor */ template void accept(basic_socket& peer, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { asio::error_code ec; impl_.get_service().accept(impl_.get_implementation(), @@ -1325,9 +1317,9 @@ class basic_socket_acceptor template ASIO_SYNC_OP_VOID accept( basic_socket& peer, asio::error_code& ec, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { impl_.get_service().accept(impl_.get_implementation(), peer, static_cast(0), ec); @@ -1391,19 +1383,16 @@ class basic_socket_acceptor */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(AcceptToken, - void (asio::error_code)) - async_accept(basic_socket& peer, - ASIO_MOVE_ARG(AcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type), - typename constraint< + AcceptToken = default_completion_token_t> + auto async_accept(basic_socket& peer, + AcceptToken&& token = default_completion_token_t(), + constraint_t< is_convertible::value - >::type = 0) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + > = 0) + -> decltype( async_initiate( - declval(), token, - &peer, static_cast(0)))) + declval(), token, + &peer, static_cast(0))) { return async_initiate( initiate_async_accept(this), token, @@ -1524,23 +1513,19 @@ class basic_socket_acceptor */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(AcceptToken, - void (asio::error_code)) - async_accept(basic_socket& peer, + AcceptToken = default_completion_token_t> + auto async_accept(basic_socket& peer, endpoint_type& peer_endpoint, - ASIO_MOVE_ARG(AcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + AcceptToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, &peer, &peer_endpoint))) + declval(), token, &peer, &peer_endpoint)) { return async_initiate( initiate_async_accept(this), token, &peer, &peer_endpoint); } #endif // !defined(ASIO_NO_EXTENSIONS) -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Accept a new connection. /** * This function is used to accept a new connection from a peer. The function @@ -1670,22 +1655,17 @@ class basic_socket_acceptor ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code, typename Protocol::socket::template rebind_executor< executor_type>::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template - rebind_executor::other)) - async_accept( - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + = default_completion_token_t> + auto async_accept( + MoveAcceptToken&& token = default_completion_token_t()) + -> decltype( async_initiate::other)>( declval(), token, - declval(), static_cast(0), + declval(), static_cast(0), static_cast::other*>(0)))) + rebind_executor::other*>(0))) { return async_initiate typename Protocol::socket::template rebind_executor::other accept(const Executor1& ex, - typename constraint< + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) + > = 0) { asio::error_code ec; typename Protocol::socket::template @@ -1762,9 +1742,9 @@ class basic_socket_acceptor typename Protocol::socket::template rebind_executor< typename ExecutionContext::executor_type>::other accept(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { asio::error_code ec; typename Protocol::socket::template rebind_executor< @@ -1805,10 +1785,10 @@ class basic_socket_acceptor template typename Protocol::socket::template rebind_executor::other accept(const Executor1& ex, asio::error_code& ec, - typename constraint< + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) + > = 0) { typename Protocol::socket::template rebind_executor::other peer(ex); @@ -1848,9 +1828,9 @@ class basic_socket_acceptor typename Protocol::socket::template rebind_executor< typename ExecutionContext::executor_type>::other accept(ExecutionContext& context, asio::error_code& ec, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { typename Protocol::socket::template rebind_executor< typename ExecutionContext::executor_type>::other peer(context); @@ -1924,22 +1904,17 @@ class basic_socket_acceptor template ::value + constraint_t::value || execution::is_executor::value, - Executor1>::type>::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template rebind_executor< - Executor1>::other)) - async_accept(const Executor1& ex, - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type), - typename constraint< + Executor1>>::other)) MoveAcceptToken + = default_completion_token_t> + auto async_accept(const Executor1& ex, + MoveAcceptToken&& token = default_completion_token_t(), + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + > = 0) + -> decltype( async_initiate(), token, ex, static_cast(0), static_cast::other*>(0)))) + rebind_executor::other*>(0))) { return async_initiate::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template rebind_executor< - typename ExecutionContext::executor_type>::other)) - async_accept(ExecutionContext& context, - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type), - typename constraint< + = default_completion_token_t> + auto async_accept(ExecutionContext& context, + MoveAcceptToken&& token = default_completion_token_t(), + constraint_t< is_convertible::value - >::type = 0) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + > = 0) + -> decltype( async_initiate(), token, context.get_executor(), static_cast(0), static_cast::other*>(0)))) + typename ExecutionContext::executor_type>::other*>(0))) { return async_initiate::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template - rebind_executor::other)) - async_accept(endpoint_type& peer_endpoint, - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + = default_completion_token_t> + auto async_accept(endpoint_type& peer_endpoint, + MoveAcceptToken&& token = default_completion_token_t()) + -> decltype( async_initiate::other)>( declval(), token, - declval(), &peer_endpoint, + declval(), &peer_endpoint, static_cast::other*>(0)))) + rebind_executor::other*>(0))) { return async_initiate typename Protocol::socket::template rebind_executor::other accept(const Executor1& ex, endpoint_type& peer_endpoint, - typename constraint< + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) + > = 0) { asio::error_code ec; typename Protocol::socket::template @@ -2305,9 +2270,9 @@ class basic_socket_acceptor typename Protocol::socket::template rebind_executor< typename ExecutionContext::executor_type>::other accept(ExecutionContext& context, endpoint_type& peer_endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { asio::error_code ec; typename Protocol::socket::template rebind_executor< @@ -2355,10 +2320,10 @@ class basic_socket_acceptor typename Protocol::socket::template rebind_executor::other accept(const executor_type& ex, endpoint_type& peer_endpoint, asio::error_code& ec, - typename constraint< + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) + > = 0) { typename Protocol::socket::template rebind_executor::other peer(ex); @@ -2405,9 +2370,9 @@ class basic_socket_acceptor typename ExecutionContext::executor_type>::other accept(ExecutionContext& context, endpoint_type& peer_endpoint, asio::error_code& ec, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) { typename Protocol::socket::template rebind_executor< typename ExecutionContext::executor_type>::other peer(context); @@ -2488,29 +2453,24 @@ class basic_socket_acceptor template ::value + constraint_t::value || execution::is_executor::value, - Executor1>::type>::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template rebind_executor< - Executor1>::other)) - async_accept(const Executor1& ex, endpoint_type& peer_endpoint, - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type), - typename constraint< + Executor1>>::other)) MoveAcceptToken + = default_completion_token_t> + auto async_accept(const Executor1& ex, endpoint_type& peer_endpoint, + MoveAcceptToken&& token = default_completion_token_t(), + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + > = 0) + -> decltype( async_initiate::other)>( declval(), token, ex, &peer_endpoint, static_cast::other*>(0)))) + rebind_executor::other*>(0))) { return async_initiate::other)) MoveAcceptToken - ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(MoveAcceptToken, - void (asio::error_code, - typename Protocol::socket::template rebind_executor< - typename ExecutionContext::executor_type>::other)) - async_accept(ExecutionContext& context, - endpoint_type& peer_endpoint, - ASIO_MOVE_ARG(MoveAcceptToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type), - typename constraint< + = default_completion_token_t> + auto async_accept(ExecutionContext& context, endpoint_type& peer_endpoint, + MoveAcceptToken&& token = default_completion_token_t(), + constraint_t< is_convertible::value - >::type = 0) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + > = 0) + -> decltype( async_initiate(), token, context.get_executor(), &peer_endpoint, static_cast::other*>(0)))) + typename ExecutionContext::executor_type>::other*>(0))) { return async_initiate::other*>(0)); } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) private: // Disallow copying and assignment. - basic_socket_acceptor(const basic_socket_acceptor&) ASIO_DELETED; + basic_socket_acceptor(const basic_socket_acceptor&) = delete; basic_socket_acceptor& operator=( - const basic_socket_acceptor&) ASIO_DELETED; + const basic_socket_acceptor&) = delete; class initiate_async_wait { @@ -2643,13 +2596,13 @@ class basic_socket_acceptor { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WaitHandler) handler, wait_type w) const + void operator()(WaitHandler&& handler, wait_type w) const { // If you get an error on the following line it means that your handler // does not meet the documented type requirements for a WaitHandler. @@ -2675,13 +2628,13 @@ class basic_socket_acceptor { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(AcceptHandler) handler, + void operator()(AcceptHandler&& handler, basic_socket* peer, endpoint_type* peer_endpoint) const { @@ -2709,13 +2662,13 @@ class basic_socket_acceptor { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(MoveAcceptHandler) handler, + void operator()(MoveAcceptHandler&& handler, const Executor1& peer_ex, endpoint_type* peer_endpoint, Socket*) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/basic_socket_iostream.hpp b/asio/include/asio/basic_socket_iostream.hpp index 13e73eb435..00ed1c4b6e 100644 --- a/asio/include/asio/basic_socket_iostream.hpp +++ b/asio/include/asio/basic_socket_iostream.hpp @@ -23,55 +23,6 @@ #include #include "asio/basic_socket_streambuf.hpp" -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) - -# include "asio/detail/variadic_templates.hpp" - -// A macro that should expand to: -// template -// explicit basic_socket_iostream(T1 x1, ..., Tn xn) -// : std::basic_iostream( -// &this->detail::socket_iostream_base< -// Protocol, Clock, WaitTraits>::streambuf_) -// { -// if (rdbuf()->connect(x1, ..., xn) == 0) -// this->setstate(std::ios_base::failbit); -// } -// This macro should only persist within this file. - -# define ASIO_PRIVATE_CTR_DEF(n) \ - template \ - explicit basic_socket_iostream(ASIO_VARIADIC_BYVAL_PARAMS(n)) \ - : std::basic_iostream( \ - &this->detail::socket_iostream_base< \ - Protocol, Clock, WaitTraits>::streambuf_) \ - { \ - this->setf(std::ios_base::unitbuf); \ - if (rdbuf()->connect(ASIO_VARIADIC_BYVAL_ARGS(n)) == 0) \ - this->setstate(std::ios_base::failbit); \ - } \ - /**/ - -// A macro that should expand to: -// template -// void connect(T1 x1, ..., Tn xn) -// { -// if (rdbuf()->connect(x1, ..., xn) == 0) -// this->setstate(std::ios_base::failbit); -// } -// This macro should only persist within this file. - -# define ASIO_PRIVATE_CONNECT_DEF(n) \ - template \ - void connect(ASIO_VARIADIC_BYVAL_PARAMS(n)) \ - { \ - if (rdbuf()->connect(ASIO_VARIADIC_BYVAL_ARGS(n)) == 0) \ - this->setstate(std::ios_base::failbit); \ - } \ - /**/ - -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #include "asio/detail/push_options.hpp" namespace asio { @@ -87,7 +38,6 @@ class socket_iostream_base { } -#if defined(ASIO_HAS_MOVE) socket_iostream_base(socket_iostream_base&& other) : streambuf_(std::move(other.streambuf_)) { @@ -103,7 +53,6 @@ class socket_iostream_base streambuf_ = std::move(other.streambuf_); return *this; } -#endif // defined(ASIO_HAS_MOVE) basic_socket_streambuf streambuf_; }; @@ -118,11 +67,11 @@ template > + typename WaitTraits = time_traits> #else // defined(ASIO_HAS_BOOST_DATE_TIME) // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typename Clock = chrono::steady_clock, - typename WaitTraits = wait_traits > + typename WaitTraits = wait_traits> #endif // defined(ASIO_HAS_BOOST_DATE_TIME) // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) class basic_socket_iostream; @@ -133,7 +82,7 @@ class basic_socket_iostream; #if defined(GENERATING_DOCUMENTATION) template > + typename WaitTraits = wait_traits> #else // defined(GENERATING_DOCUMENTATION) template #endif // defined(GENERATING_DOCUMENTATION) @@ -193,7 +142,6 @@ class basic_socket_iostream this->setf(std::ios_base::unitbuf); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct a basic_socket_iostream from the supplied socket. explicit basic_socket_iostream(basic_stream_socket s) : detail::socket_iostream_base< @@ -205,8 +153,6 @@ class basic_socket_iostream this->setf(std::ios_base::unitbuf); } -#if defined(ASIO_HAS_STD_IOSTREAM_MOVE) \ - || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_socket_iostream from another. basic_socket_iostream(basic_socket_iostream&& other) : detail::socket_iostream_base< @@ -225,20 +171,13 @@ class basic_socket_iostream Protocol, Clock, WaitTraits>::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_STD_IOSTREAM_MOVE) - // || defined(GENERATING_DOCUMENTATION) -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) -#if defined(GENERATING_DOCUMENTATION) /// Establish a connection to an endpoint corresponding to a resolver query. /** * This constructor automatically establishes a connection based on the * supplied resolver query parameters. The arguments are used to construct * a resolver query object. */ - template - explicit basic_socket_iostream(T1 t1, ..., TN tn); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) template explicit basic_socket_iostream(T... x) : std::basic_iostream( @@ -249,29 +188,19 @@ class basic_socket_iostream if (rdbuf()->connect(x...) == 0) this->setstate(std::ios_base::failbit); } -#else - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_CTR_DEF) -#endif -#if defined(GENERATING_DOCUMENTATION) /// Establish a connection to an endpoint corresponding to a resolver query. /** * This function automatically establishes a connection based on the supplied * resolver query parameters. The arguments are used to construct a resolver * query object. */ - template - void connect(T1 t1, ..., TN tn); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) template void connect(T... x) { if (rdbuf()->connect(x...) == 0) this->setstate(std::ios_base::failbit); } -#else - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_CONNECT_DEF) -#endif /// Close the connection. void close() @@ -388,20 +317,15 @@ class basic_socket_iostream private: // Disallow copying and assignment. - basic_socket_iostream(const basic_socket_iostream&) ASIO_DELETED; + basic_socket_iostream(const basic_socket_iostream&) = delete; basic_socket_iostream& operator=( - const basic_socket_iostream&) ASIO_DELETED; + const basic_socket_iostream&) = delete; }; } // namespace asio #include "asio/detail/pop_options.hpp" -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) -# undef ASIO_PRIVATE_CTR_DEF -# undef ASIO_PRIVATE_CONNECT_DEF -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #endif // !defined(ASIO_NO_IOSTREAM) #endif // ASIO_BASIC_SOCKET_IOSTREAM_HPP diff --git a/asio/include/asio/basic_socket_streambuf.hpp b/asio/include/asio/basic_socket_streambuf.hpp index cdfb24a852..a1d557d6cb 100644 --- a/asio/include/asio/basic_socket_streambuf.hpp +++ b/asio/include/asio/basic_socket_streambuf.hpp @@ -37,38 +37,6 @@ #endif // defined(ASIO_HAS_BOOST_DATE_TIME) // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) - -# include "asio/detail/variadic_templates.hpp" - -// A macro that should expand to: -// template -// basic_socket_streambuf* connect(T1 x1, ..., Tn xn) -// { -// init_buffers(); -// typedef typename Protocol::resolver resolver_type; -// resolver_type resolver(socket().get_executor()); -// connect_to_endpoints( -// resolver.resolve(x1, ..., xn, ec_)); -// return !ec_ ? this : 0; -// } -// This macro should only persist within this file. - -# define ASIO_PRIVATE_CONNECT_DEF(n) \ - template \ - basic_socket_streambuf* connect(ASIO_VARIADIC_BYVAL_PARAMS(n)) \ - { \ - init_buffers(); \ - typedef typename Protocol::resolver resolver_type; \ - resolver_type resolver(socket().get_executor()); \ - connect_to_endpoints( \ - resolver.resolve(ASIO_VARIADIC_BYVAL_ARGS(n), ec_)); \ - return !ec_ ? this : 0; \ - } \ - /**/ - -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #include "asio/detail/push_options.hpp" namespace asio { @@ -116,11 +84,11 @@ template > + typename WaitTraits = time_traits> #else // defined(ASIO_HAS_BOOST_DATE_TIME) // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typename Clock = chrono::steady_clock, - typename WaitTraits = wait_traits > + typename WaitTraits = wait_traits> #endif // defined(ASIO_HAS_BOOST_DATE_TIME) // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) class basic_socket_streambuf; @@ -131,7 +99,7 @@ class basic_socket_streambuf; #if defined(GENERATING_DOCUMENTATION) template > + typename WaitTraits = wait_traits> #else // defined(GENERATING_DOCUMENTATION) template #endif // defined(GENERATING_DOCUMENTATION) @@ -197,7 +165,6 @@ class basic_socket_streambuf init_buffers(); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct a basic_socket_streambuf from the supplied socket. explicit basic_socket_streambuf(basic_stream_socket s) : detail::socket_streambuf_io_context(0), @@ -241,7 +208,6 @@ class basic_socket_streambuf other.init_buffers(); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destructor flushes buffered data. virtual ~basic_socket_streambuf() @@ -265,7 +231,6 @@ class basic_socket_streambuf return !ec_ ? this : 0; } -#if defined(GENERATING_DOCUMENTATION) /// Establish a connection. /** * This function automatically establishes a connection based on the supplied @@ -275,9 +240,6 @@ class basic_socket_streambuf * @return \c this if a connection was successfully established, a null * pointer otherwise. */ - template - basic_socket_streambuf* connect(T1 t1, ..., TN tn); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) template basic_socket_streambuf* connect(T... x) { @@ -287,9 +249,6 @@ class basic_socket_streambuf connect_to_endpoints(resolver.resolve(x..., ec_)); return !ec_ ? this : 0; } -#else - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_CONNECT_DEF) -#endif /// Close the connection. /** @@ -559,9 +518,9 @@ class basic_socket_streambuf private: // Disallow copying and assignment. - basic_socket_streambuf(const basic_socket_streambuf&) ASIO_DELETED; + basic_socket_streambuf(const basic_socket_streambuf&) = delete; basic_socket_streambuf& operator=( - const basic_socket_streambuf&) ASIO_DELETED; + const basic_socket_streambuf&) = delete; void init_buffers() { @@ -678,10 +637,6 @@ class basic_socket_streambuf #include "asio/detail/pop_options.hpp" -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) -# undef ASIO_PRIVATE_CONNECT_DEF -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #endif // !defined(ASIO_NO_IOSTREAM) #endif // ASIO_BASIC_SOCKET_STREAMBUF_HPP diff --git a/asio/include/asio/basic_stream_file.hpp b/asio/include/asio/basic_stream_file.hpp index af47d0d1d4..227c3088e8 100644 --- a/asio/include/asio/basic_stream_file.hpp +++ b/asio/include/asio/basic_stream_file.hpp @@ -106,10 +106,10 @@ class basic_stream_file */ template explicit basic_stream_file(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context) { this->impl_.get_service().set_is_stream( @@ -161,10 +161,10 @@ class basic_stream_file template basic_stream_file(ExecutionContext& context, const char* path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context) { asio::error_code ec; @@ -221,10 +221,10 @@ class basic_stream_file template basic_stream_file(ExecutionContext& context, const std::string& path, file_base::flags open_flags, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context) { asio::error_code ec; @@ -272,17 +272,16 @@ class basic_stream_file template basic_stream_file(ExecutionContext& context, const native_handle_type& native_file, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(context, native_file) { this->impl_.get_service().set_is_stream( this->impl_.get_implementation(), true); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_stream_file from another. /** * This constructor moves a stream file from one object to another. @@ -294,7 +293,7 @@ class basic_stream_file * constructed using the @c basic_stream_file(const executor_type&) * constructor. */ - basic_stream_file(basic_stream_file&& other) ASIO_NOEXCEPT + basic_stream_file(basic_stream_file&& other) noexcept : basic_file(std::move(other)) { } @@ -330,10 +329,10 @@ class basic_stream_file */ template basic_stream_file(basic_stream_file&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_file(std::move(other)) { } @@ -350,15 +349,14 @@ class basic_stream_file * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_stream_file& - >::type operator=(basic_stream_file&& other) + > operator=(basic_stream_file&& other) { basic_file::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the file. /** @@ -522,17 +520,13 @@ class basic_stream_file */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_write_some(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_write_some(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -655,17 +649,13 @@ class basic_stream_file */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_read_some(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_read_some(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -674,8 +664,8 @@ class basic_stream_file private: // Disallow copying and assignment. - basic_stream_file(const basic_stream_file&) ASIO_DELETED; - basic_stream_file& operator=(const basic_stream_file&) ASIO_DELETED; + basic_stream_file(const basic_stream_file&) = delete; + basic_stream_file& operator=(const basic_stream_file&) = delete; class initiate_async_write_some { @@ -687,13 +677,13 @@ class basic_stream_file { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers) const { // If you get an error on the following line it means that your handler @@ -720,13 +710,13 @@ class basic_stream_file { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/basic_stream_socket.hpp b/asio/include/asio/basic_stream_socket.hpp index afe7c765be..8a0cd32808 100644 --- a/asio/include/asio/basic_stream_socket.hpp +++ b/asio/include/asio/basic_stream_socket.hpp @@ -116,9 +116,9 @@ class basic_stream_socket */ template explicit basic_stream_socket(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context) { } @@ -155,10 +155,10 @@ class basic_stream_socket */ template basic_stream_socket(ExecutionContext& context, const protocol_type& protocol, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : basic_socket(context, protocol) { } @@ -201,9 +201,9 @@ class basic_stream_socket */ template basic_stream_socket(ExecutionContext& context, const endpoint_type& endpoint, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, endpoint) { } @@ -246,14 +246,13 @@ class basic_stream_socket template basic_stream_socket(ExecutionContext& context, const protocol_type& protocol, const native_handle_type& native_socket, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : basic_socket(context, protocol, native_socket) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_stream_socket from another. /** * This constructor moves a stream socket from one object to another. @@ -265,7 +264,7 @@ class basic_stream_socket * constructed using the @c basic_stream_socket(const executor_type&) * constructor. */ - basic_stream_socket(basic_stream_socket&& other) ASIO_NOEXCEPT + basic_stream_socket(basic_stream_socket&& other) noexcept : basic_socket(std::move(other)) { } @@ -301,10 +300,10 @@ class basic_stream_socket */ template basic_stream_socket(basic_stream_socket&& other, - typename constraint< + constraint_t< is_convertible::value && is_convertible::value - >::type = 0) + > = 0) : basic_socket(std::move(other)) { } @@ -321,16 +320,15 @@ class basic_stream_socket * constructor. */ template - typename constraint< + constraint_t< is_convertible::value && is_convertible::value, basic_stream_socket& - >::type operator=(basic_stream_socket&& other) + > operator=(basic_stream_socket&& other) { basic_socket::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the socket. /** @@ -493,18 +491,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -567,18 +561,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_send(const ConstBufferSequence& buffers, + std::size_t)) WriteToken = default_completion_token_t> + auto async_send(const ConstBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -745,18 +735,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -821,18 +807,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_receive(const MutableBufferSequence& buffers, + std::size_t)) ReadToken = default_completion_token_t> + auto async_receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers, flags))) + declval(), token, buffers, flags)) { return async_initiate( @@ -953,18 +935,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_write_some(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_write_some(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -1089,18 +1067,14 @@ class basic_stream_socket */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken, - void (asio::error_code, std::size_t)) - async_read_some(const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) ReadToken = default_completion_token_t> + auto async_read_some(const MutableBufferSequence& buffers, + ReadToken&& token = default_completion_token_t()) + -> decltype( async_initiate( declval(), token, - buffers, socket_base::message_flags(0)))) + buffers, socket_base::message_flags(0))) { return async_initiate( @@ -1110,8 +1084,8 @@ class basic_stream_socket private: // Disallow copying and assignment. - basic_stream_socket(const basic_stream_socket&) ASIO_DELETED; - basic_stream_socket& operator=(const basic_stream_socket&) ASIO_DELETED; + basic_stream_socket(const basic_stream_socket&) = delete; + basic_stream_socket& operator=(const basic_stream_socket&) = delete; class initiate_async_send { @@ -1123,13 +1097,13 @@ class basic_stream_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers, socket_base::message_flags flags) const { @@ -1157,13 +1131,13 @@ class basic_stream_socket { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers, socket_base::message_flags flags) const { diff --git a/asio/include/asio/basic_streambuf.hpp b/asio/include/asio/basic_streambuf.hpp index 61e6dc4c39..d652669354 100644 --- a/asio/include/asio/basic_streambuf.hpp +++ b/asio/include/asio/basic_streambuf.hpp @@ -103,7 +103,7 @@ namespace asio { * @endcode */ #if defined(GENERATING_DOCUMENTATION) -template > +template > #else template #endif @@ -155,7 +155,7 @@ class basic_streambuf * } * @endcode */ - std::size_t size() const ASIO_NOEXCEPT + std::size_t size() const noexcept { return pptr() - gptr(); } @@ -165,7 +165,7 @@ class basic_streambuf * @returns The allowed maximum of the sum of the sizes of the input sequence * and output sequence. */ - std::size_t max_size() const ASIO_NOEXCEPT + std::size_t max_size() const noexcept { return max_size_; } @@ -175,7 +175,7 @@ class basic_streambuf * @returns The current total capacity of the streambuf, i.e. for both the * input sequence and output sequence. */ - std::size_t capacity() const ASIO_NOEXCEPT + std::size_t capacity() const noexcept { return buffer_.capacity(); } @@ -189,7 +189,7 @@ class basic_streambuf * @note The returned object is invalidated by any @c basic_streambuf member * function that modifies the input sequence or output sequence. */ - const_buffers_type data() const ASIO_NOEXCEPT + const_buffers_type data() const noexcept { return asio::buffer(asio::const_buffer(gptr(), (pptr() - gptr()) * sizeof(char_type))); @@ -361,7 +361,7 @@ class basic_streambuf /// Adapts basic_streambuf to the dynamic buffer sequence type requirements. #if defined(GENERATING_DOCUMENTATION) -template > +template > #else template #endif @@ -383,39 +383,37 @@ class basic_streambuf_ref } /// Copy construct a basic_streambuf_ref. - basic_streambuf_ref(const basic_streambuf_ref& other) ASIO_NOEXCEPT + basic_streambuf_ref(const basic_streambuf_ref& other) noexcept : sb_(other.sb_) { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move construct a basic_streambuf_ref. - basic_streambuf_ref(basic_streambuf_ref&& other) ASIO_NOEXCEPT + basic_streambuf_ref(basic_streambuf_ref&& other) noexcept : sb_(other.sb_) { } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get the size of the input sequence. - std::size_t size() const ASIO_NOEXCEPT + std::size_t size() const noexcept { return sb_.size(); } /// Get the maximum size of the dynamic buffer. - std::size_t max_size() const ASIO_NOEXCEPT + std::size_t max_size() const noexcept { return sb_.max_size(); } /// Get the current capacity of the dynamic buffer. - std::size_t capacity() const ASIO_NOEXCEPT + std::size_t capacity() const noexcept { return sb_.capacity(); } /// Get a list of buffers that represents the input sequence. - const_buffers_type data() const ASIO_NOEXCEPT + const_buffers_type data() const noexcept { return sb_.data(); } diff --git a/asio/include/asio/basic_streambuf_fwd.hpp b/asio/include/asio/basic_streambuf_fwd.hpp index 2f74881e30..098c270657 100644 --- a/asio/include/asio/basic_streambuf_fwd.hpp +++ b/asio/include/asio/basic_streambuf_fwd.hpp @@ -23,10 +23,10 @@ namespace asio { -template > +template > class basic_streambuf; -template > +template > class basic_streambuf_ref; } // namespace asio diff --git a/asio/include/asio/basic_waitable_timer.hpp b/asio/include/asio/basic_waitable_timer.hpp index dccb546ac9..579816b140 100644 --- a/asio/include/asio/basic_waitable_timer.hpp +++ b/asio/include/asio/basic_waitable_timer.hpp @@ -17,6 +17,7 @@ #include "asio/detail/config.hpp" #include +#include #include "asio/any_io_executor.hpp" #include "asio/detail/chrono_time_traits.hpp" #include "asio/detail/deadline_timer_service.hpp" @@ -27,10 +28,6 @@ #include "asio/error.hpp" #include "asio/wait_traits.hpp" -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -194,9 +191,9 @@ class basic_waitable_timer */ template explicit basic_waitable_timer(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { } @@ -233,9 +230,9 @@ class basic_waitable_timer template explicit basic_waitable_timer(ExecutionContext& context, const time_point& expiry_time, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -276,9 +273,9 @@ class basic_waitable_timer template explicit basic_waitable_timer(ExecutionContext& context, const duration& expiry_time, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -287,7 +284,6 @@ class basic_waitable_timer asio::detail::throw_error(ec, "expires_after"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_waitable_timer from another. /** * This constructor moves a timer from one object to another. @@ -340,9 +336,9 @@ class basic_waitable_timer template basic_waitable_timer( basic_waitable_timer&& other, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(std::move(other.impl_)) { } @@ -360,16 +356,15 @@ class basic_waitable_timer * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_waitable_timer& - >::type operator=(basic_waitable_timer&& other) + > operator=(basic_waitable_timer&& other) { basic_waitable_timer tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the timer. /** @@ -381,7 +376,7 @@ class basic_waitable_timer } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -768,15 +763,12 @@ class basic_waitable_timer */ template < ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code)) - WaitToken ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX( - WaitToken, void (asio::error_code)) - async_wait( - ASIO_MOVE_ARG(WaitToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + WaitToken = default_completion_token_t> + auto async_wait( + WaitToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token))) + declval(), token)) { return async_initiate( initiate_async_wait(this), token); @@ -784,9 +776,8 @@ class basic_waitable_timer private: // Disallow copying and assignment. - basic_waitable_timer(const basic_waitable_timer&) ASIO_DELETED; - basic_waitable_timer& operator=( - const basic_waitable_timer&) ASIO_DELETED; + basic_waitable_timer(const basic_waitable_timer&) = delete; + basic_waitable_timer& operator=(const basic_waitable_timer&) = delete; class initiate_async_wait { @@ -798,13 +789,13 @@ class basic_waitable_timer { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WaitHandler) handler) const + void operator()(WaitHandler&& handler) const { // If you get an error on the following line it means that your handler // does not meet the documented type requirements for a WaitHandler. @@ -822,7 +813,7 @@ class basic_waitable_timer detail::io_object_impl< detail::deadline_timer_service< - detail::chrono_time_traits >, + detail::chrono_time_traits>, executor_type > impl_; }; diff --git a/asio/include/asio/basic_writable_pipe.hpp b/asio/include/asio/basic_writable_pipe.hpp index 3c305fa9be..108f37cfe2 100644 --- a/asio/include/asio/basic_writable_pipe.hpp +++ b/asio/include/asio/basic_writable_pipe.hpp @@ -21,6 +21,7 @@ || defined(GENERATING_DOCUMENTATION) #include +#include #include "asio/any_io_executor.hpp" #include "asio/async_result.hpp" #include "asio/detail/handler_type_requirements.hpp" @@ -38,10 +39,6 @@ # include "asio/detail/reactive_descriptor_service.hpp" #endif -#if defined(ASIO_HAS_MOVE) -# include -#endif // defined(ASIO_HAS_MOVE) - #include "asio/detail/push_options.hpp" namespace asio { @@ -112,10 +109,10 @@ class basic_writable_pipe */ template explicit basic_writable_pipe(ExecutionContext& context, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(0, 0, context) { } @@ -159,9 +156,9 @@ class basic_writable_pipe template basic_writable_pipe(ExecutionContext& context, const native_handle_type& native_pipe, - typename constraint< + constraint_t< is_convertible::value - >::type = 0) + > = 0) : impl_(0, 0, context) { asio::error_code ec; @@ -170,7 +167,6 @@ class basic_writable_pipe asio::detail::throw_error(ec, "assign"); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a basic_writable_pipe from another. /** * This constructor moves a pipe from one object to another. @@ -221,10 +217,10 @@ class basic_writable_pipe */ template basic_writable_pipe(basic_writable_pipe&& other, - typename constraint< + constraint_t< is_convertible::value, defaulted_constraint - >::type = defaulted_constraint()) + > = defaulted_constraint()) : impl_(std::move(other.impl_)) { } @@ -241,16 +237,15 @@ class basic_writable_pipe * constructor. */ template - typename constraint< + constraint_t< is_convertible::value, basic_writable_pipe& - >::type operator=(basic_writable_pipe&& other) + > operator=(basic_writable_pipe&& other) { basic_writable_pipe tmp(std::move(other)); impl_ = std::move(tmp.impl_); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Destroys the pipe. /** @@ -263,7 +258,7 @@ class basic_writable_pipe } /// Get the executor associated with the object. - const executor_type& get_executor() ASIO_NOEXCEPT + const executor_type& get_executor() noexcept { return impl_.get_executor(); } @@ -557,17 +552,13 @@ class basic_writable_pipe */ template - ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken, - void (asio::error_code, std::size_t)) - async_write_some(const ConstBufferSequence& buffers, - ASIO_MOVE_ARG(WriteToken) token - ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + std::size_t)) WriteToken = default_completion_token_t> + auto async_write_some(const ConstBufferSequence& buffers, + WriteToken&& token = default_completion_token_t()) + -> decltype( async_initiate( - declval(), token, buffers))) + declval(), token, buffers)) { return async_initiate( @@ -576,8 +567,8 @@ class basic_writable_pipe private: // Disallow copying and assignment. - basic_writable_pipe(const basic_writable_pipe&) ASIO_DELETED; - basic_writable_pipe& operator=(const basic_writable_pipe&) ASIO_DELETED; + basic_writable_pipe(const basic_writable_pipe&) = delete; + basic_writable_pipe& operator=(const basic_writable_pipe&) = delete; class initiate_async_write_some { @@ -589,13 +580,13 @@ class basic_writable_pipe { } - const executor_type& get_executor() const ASIO_NOEXCEPT + const executor_type& get_executor() const noexcept { return self_->get_executor(); } template - void operator()(ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers) const { // If you get an error on the following line it means that your handler diff --git a/asio/include/asio/bind_allocator.hpp b/asio/include/asio/bind_allocator.hpp index c7896666fe..d6f636c964 100644 --- a/asio/include/asio/bind_allocator.hpp +++ b/asio/include/asio/bind_allocator.hpp @@ -17,7 +17,6 @@ #include "asio/detail/config.hpp" #include "asio/detail/type_traits.hpp" -#include "asio/detail/variadic_templates.hpp" #include "asio/associated_allocator.hpp" #include "asio/associator.hpp" #include "asio/async_result.hpp" @@ -37,8 +36,7 @@ struct allocator_binder_result_type }; template -struct allocator_binder_result_type::type> +struct allocator_binder_result_type> { typedef typename T::result_type result_type; protected: @@ -99,8 +97,7 @@ template struct allocator_binder_argument_type {}; template -struct allocator_binder_argument_type::type> +struct allocator_binder_argument_type> { typedef typename T::argument_type argument_type; }; @@ -125,7 +122,7 @@ struct allocator_binder_argument_types {}; template struct allocator_binder_argument_types::type> + void_t> { typedef typename T::first_argument_type first_argument_type; typedef typename T::second_argument_type second_argument_type; @@ -145,21 +142,6 @@ struct allocator_binder_argument_type typedef A2 second_argument_type; }; -// Helper to enable SFINAE on zero-argument operator() below. - -template -struct allocator_binder_result_of0 -{ - typedef void type; -}; - -template -struct allocator_binder_result_of0::type>::type> -{ - typedef typename result_of::type type; -}; - } // namespace detail /// A call wrapper type to bind an allocator of type @c Allocator @@ -247,10 +229,9 @@ class allocator_binder * @c U. */ template - allocator_binder(const allocator_type& s, - ASIO_MOVE_ARG(U) u) + allocator_binder(const allocator_type& s, U&& u) : allocator_(s), - target_(ASIO_MOVE_CAST(U)(u)) + target_(static_cast(u)) { } @@ -262,8 +243,7 @@ class allocator_binder } /// Construct a copy, but specify a different allocator. - allocator_binder(const allocator_type& s, - const allocator_binder& other) + allocator_binder(const allocator_type& s, const allocator_binder& other) : allocator_(s), target_(other.get()) { @@ -276,8 +256,7 @@ class allocator_binder * constructible from type @c U. */ template - allocator_binder( - const allocator_binder& other) + allocator_binder(const allocator_binder& other) : allocator_(other.get_allocator()), target_(other.get()) { @@ -297,13 +276,11 @@ class allocator_binder { } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// Move constructor. allocator_binder(allocator_binder&& other) - : allocator_(ASIO_MOVE_CAST(allocator_type)( + : allocator_(static_cast( other.get_allocator())), - target_(ASIO_MOVE_CAST(T)(other.get())) + target_(static_cast(other.get())) { } @@ -311,7 +288,7 @@ class allocator_binder allocator_binder(const allocator_type& s, allocator_binder&& other) : allocator_(s), - target_(ASIO_MOVE_CAST(T)(other.get())) + target_(static_cast(other.get())) { } @@ -319,9 +296,9 @@ class allocator_binder template allocator_binder( allocator_binder&& other) - : allocator_(ASIO_MOVE_CAST(OtherAllocator)( + : allocator_(static_cast( other.get_allocator())), - target_(ASIO_MOVE_CAST(U)(other.get())) + target_(static_cast(other.get())) { } @@ -331,124 +308,47 @@ class allocator_binder allocator_binder(const allocator_type& s, allocator_binder&& other) : allocator_(s), - target_(ASIO_MOVE_CAST(U)(other.get())) + target_(static_cast(other.get())) { } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// Destructor. ~allocator_binder() { } /// Obtain a reference to the target object. - target_type& get() ASIO_NOEXCEPT + target_type& get() noexcept { return target_; } /// Obtain a reference to the target object. - const target_type& get() const ASIO_NOEXCEPT + const target_type& get() const noexcept { return target_; } /// Obtain the associated allocator. - allocator_type get_allocator() const ASIO_NOEXCEPT + allocator_type get_allocator() const noexcept { return allocator_; } -#if defined(GENERATING_DOCUMENTATION) - - template auto operator()(Args&& ...); - template auto operator()(Args&& ...) const; - -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) - /// Forwarding function call operator. template - typename result_of::type operator()( - ASIO_MOVE_ARG(Args)... args) + result_of_t operator()(Args&&... args) { - return target_(ASIO_MOVE_CAST(Args)(args)...); + return target_(static_cast(args)...); } /// Forwarding function call operator. template - typename result_of::type operator()( - ASIO_MOVE_ARG(Args)... args) const - { - return target_(ASIO_MOVE_CAST(Args)(args)...); - } - -#elif defined(ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER) - - typename detail::allocator_binder_result_of0::type operator()() - { - return target_(); - } - - typename detail::allocator_binder_result_of0::type - operator()() const - { - return target_(); - } - -#define ASIO_PRIVATE_BINDER_CALL_DEF(n) \ - template \ - typename result_of::type operator()( \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return target_(ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - typename result_of::type operator()( \ - ASIO_VARIADIC_MOVE_PARAMS(n)) const \ - { \ - return target_(ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_BINDER_CALL_DEF) -#undef ASIO_PRIVATE_BINDER_CALL_DEF - -#else // defined(ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER) - - typedef typename detail::allocator_binder_result_type< - T>::result_type_or_void result_type_or_void; - - result_type_or_void operator()() - { - return target_(); - } - - result_type_or_void operator()() const + result_of_t operator()(Args&&... args) const { - return target_(); + return target_(static_cast(args)...); } -#define ASIO_PRIVATE_BINDER_CALL_DEF(n) \ - template \ - result_type_or_void operator()( \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return target_(ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - result_type_or_void operator()( \ - ASIO_VARIADIC_MOVE_PARAMS(n)) const \ - { \ - return target_(ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_BINDER_CALL_DEF) -#undef ASIO_PRIVATE_BINDER_CALL_DEF - -#endif // defined(ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER) - private: Allocator allocator_; T target_; @@ -457,20 +357,17 @@ class allocator_binder /// Associate an object of type @c T with an allocator of type /// @c Allocator. template -ASIO_NODISCARD inline allocator_binder::type, Allocator> -bind_allocator(const Allocator& s, ASIO_MOVE_ARG(T) t) +ASIO_NODISCARD inline allocator_binder, Allocator> +bind_allocator(const Allocator& s, T&& t) { - return allocator_binder< - typename decay::type, Allocator>( - s, ASIO_MOVE_CAST(T)(t)); + return allocator_binder, Allocator>(s, static_cast(t)); } #if !defined(GENERATING_DOCUMENTATION) namespace detail { -template +template class allocator_binder_completion_handler_async_result { public: @@ -482,10 +379,8 @@ class allocator_binder_completion_handler_async_result template class allocator_binder_completion_handler_async_result< - TargetAsyncResult, Allocator, - typename void_type< - typename TargetAsyncResult::completion_handler_type - >::type> + TargetAsyncResult, Allocator, + void_t> { public: typedef allocator_binder< @@ -514,10 +409,7 @@ struct allocator_binder_async_result_return_type template struct allocator_binder_async_result_return_type< - TargetAsyncResult, - typename void_type< - typename TargetAsyncResult::return_type - >::type> + TargetAsyncResult, void_type> { typedef typename TargetAsyncResult::return_type return_type; }; @@ -527,9 +419,9 @@ struct allocator_binder_async_result_return_type< template class async_result, Signature> : public detail::allocator_binder_completion_handler_async_result< - async_result, Allocator>, + async_result, Allocator>, public detail::allocator_binder_async_result_return_type< - async_result > + async_result> { public: explicit async_result(allocator_binder& b) @@ -542,199 +434,82 @@ class async_result, Signature> : struct init_wrapper { template - init_wrapper(const Allocator& allocator, ASIO_MOVE_ARG(Init) init) + init_wrapper(const Allocator& allocator, Init&& init) : allocator_(allocator), - initiation_(ASIO_MOVE_CAST(Init)(init)) + initiation_(static_cast(init)) { } -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) - template - void operator()( - ASIO_MOVE_ARG(Handler) handler, - ASIO_MOVE_ARG(Args)... args) + void operator()(Handler&& handler, Args&&... args) { - ASIO_MOVE_CAST(Initiation)(initiation_)( - allocator_binder< - typename decay::type, Allocator>( - allocator_, ASIO_MOVE_CAST(Handler)(handler)), - ASIO_MOVE_CAST(Args)(args)...); + static_cast(initiation_)( + allocator_binder, Allocator>( + allocator_, static_cast(handler)), + static_cast(args)...); } template - void operator()( - ASIO_MOVE_ARG(Handler) handler, - ASIO_MOVE_ARG(Args)... args) const + void operator()(Handler&& handler, Args&&... args) const { initiation_( - allocator_binder< - typename decay::type, Allocator>( - allocator_, ASIO_MOVE_CAST(Handler)(handler)), - ASIO_MOVE_CAST(Args)(args)...); - } - -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - - template - void operator()( - ASIO_MOVE_ARG(Handler) handler) - { - ASIO_MOVE_CAST(Initiation)(initiation_)( - allocator_binder< - typename decay::type, Allocator>( - allocator_, ASIO_MOVE_CAST(Handler)(handler))); + allocator_binder, Allocator>( + allocator_, static_cast(handler)), + static_cast(args)...); } - template - void operator()( - ASIO_MOVE_ARG(Handler) handler) const - { - initiation_( - allocator_binder< - typename decay::type, Allocator>( - allocator_, ASIO_MOVE_CAST(Handler)(handler))); - } - -#define ASIO_PRIVATE_INIT_WRAPPER_DEF(n) \ - template \ - void operator()( \ - ASIO_MOVE_ARG(Handler) handler, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - ASIO_MOVE_CAST(Initiation)(initiation_)( \ - allocator_binder< \ - typename decay::type, Allocator>( \ - allocator_, ASIO_MOVE_CAST(Handler)(handler)), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - void operator()( \ - ASIO_MOVE_ARG(Handler) handler, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) const \ - { \ - initiation_( \ - allocator_binder< \ - typename decay::type, Allocator>( \ - allocator_, ASIO_MOVE_CAST(Handler)(handler)), \ - ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INIT_WRAPPER_DEF) -#undef ASIO_PRIVATE_INIT_WRAPPER_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - Allocator allocator_; Initiation initiation_; }; -#if defined(ASIO_HAS_VARIADIC_TEMPLATES) - template - static ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature, - (async_initiate( - declval::type> >(), - declval().get(), - declval()...))) - initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token, - ASIO_MOVE_ARG(Args)... args) + static auto initiate(Initiation&& initiation, + RawCompletionToken&& token, Args&&... args) + -> decltype( + async_initiate( + declval>>(), + token.get(), static_cast(args)...)) { return async_initiate( - init_wrapper::type>( - token.get_allocator(), - ASIO_MOVE_CAST(Initiation)(initiation)), - token.get(), ASIO_MOVE_CAST(Args)(args)...); + init_wrapper>(token.get_allocator(), + static_cast(initiation)), + token.get(), static_cast(args)...); } -#else // defined(ASIO_HAS_VARIADIC_TEMPLATES) - - template - static ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature, - (async_initiate( - declval::type> >(), - declval().get()))) - initiate( - ASIO_MOVE_ARG(Initiation) initiation, - ASIO_MOVE_ARG(RawCompletionToken) token) - { - return async_initiate( - init_wrapper::type>( - token.get_allocator(), - ASIO_MOVE_CAST(Initiation)(initiation)), - token.get()); - } - -#define ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - static ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature, \ - (async_initiate( \ - declval::type> >(), \ - declval().get(), \ - ASIO_VARIADIC_MOVE_DECLVAL(n)))) \ - initiate( \ - ASIO_MOVE_ARG(Initiation) initiation, \ - ASIO_MOVE_ARG(RawCompletionToken) token, \ - ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_initiate( \ - init_wrapper::type>( \ - token.get_allocator(), \ - ASIO_MOVE_CAST(Initiation)(initiation)), \ - token.get(), ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_INITIATE_DEF) -#undef ASIO_PRIVATE_INITIATE_DEF - -#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) - 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; async_result target_; }; template