diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f4b929ded..0886d95b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get Script run: curl -OLs https://eddelbuettel.github.io/r-ci/run.sh && chmod 0755 run.sh diff --git a/ChangeLog b/ChangeLog index 04439921e..545236796 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2023-12-15 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Pre-Release 1.84.0-0 + + * .github/workflows/ci.yaml (jobs): Update to actions/checkout@v4 + +2023-12-13 Dirk Eddelbuettel + + * inst/include/boost/*: Upgraded to Boost 1.84, as usual with two + patch sets from CRAN demands on file path length and diagnostics + * local/patches/bh_1.84.0-0.diagnostics-two.patch: Added + + * local/scripts/CreateBoost.sh: Update for 1.84.0, added url + 2023-01-17 Dirk Eddelbuettel * DESCRIPTION (Version, Date): Release 1.81.0-1 diff --git a/DESCRIPTION b/DESCRIPTION index 1b3626894..1370f204a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: BH Type: Package Title: Boost C++ Header Files -Version: 1.81.0-1 -Date: 2023-01-17 +Version: 1.84.0-0 +Date: 2023-12-15 Author: Dirk Eddelbuettel, John W. Emerson and Michael J. Kane Maintainer: Dirk Eddelbuettel Description: Boost provides free peer-reviewed portable C++ source diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 61bc57639..abb2678f5 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -7,6 +7,13 @@ \newcommand{\ghit}{\href{https://github.com/eddelbuettel/bh/issues/#1}{##1}} \newcommand{\ghpr}{\href{https://github.com/eddelbuettel/bh/pull/#1}{##1}} +\section{Changes in version 1.84.0-0 (2023-12-15)}{ + \itemize{ + \item Pre-release to allow work on five affected packages + \item Upgrade to \boost 1.81.0 (\ghpr{87}) + } +} + \section{Changes in version 1.81.0-1 (2023-01-17)}{ \itemize{ \item Upgrade to \boost 1.81.0 (\ghpr{87}) diff --git a/inst/include/boost/accumulators/framework/accumulator_set.hpp b/inst/include/boost/accumulators/framework/accumulator_set.hpp index 0b4f4ad3d..e89e5e9ab 100644 --- a/inst/include/boost/accumulators/framework/accumulator_set.hpp +++ b/inst/include/boost/accumulators/framework/accumulator_set.hpp @@ -54,6 +54,11 @@ namespace detail { } + accumulator_visitor(accumulator_visitor const &other) + : args(other.args) + { + } + template void operator ()(Accumulator &accumulator) const { @@ -61,7 +66,7 @@ namespace detail } private: - accumulator_visitor &operator =(accumulator_visitor const &); + BOOST_DELETED_FUNCTION(accumulator_visitor &operator =(accumulator_visitor const &)) Args const &args; }; diff --git a/inst/include/boost/accumulators/framework/accumulators/droppable_accumulator.hpp b/inst/include/boost/accumulators/framework/accumulators/droppable_accumulator.hpp index 0e882b5c3..21fdb51bf 100644 --- a/inst/include/boost/accumulators/framework/accumulators/droppable_accumulator.hpp +++ b/inst/include/boost/accumulators/framework/accumulators/droppable_accumulator.hpp @@ -34,6 +34,11 @@ namespace boost { namespace accumulators { } + add_ref_visitor(add_ref_visitor const &other) + : args_(other.args_) + { + } + template void operator ()(Accumulator &acc) const { @@ -49,7 +54,7 @@ namespace boost { namespace accumulators } private: - add_ref_visitor &operator =(add_ref_visitor const &); + BOOST_DELETED_FUNCTION(add_ref_visitor &operator =(add_ref_visitor const &)) Args const &args_; }; @@ -87,7 +92,7 @@ namespace boost { namespace accumulators } private: - drop_visitor &operator =(drop_visitor const &); + BOOST_DELETED_FUNCTION(drop_visitor &operator =(drop_visitor const &)) Args const &args_; }; @@ -227,7 +232,7 @@ namespace boost { namespace accumulators } private: - with_cached_result &operator =(with_cached_result const &); + BOOST_DELETED_FUNCTION(with_cached_result &operator =(with_cached_result const &)) void set(result_type const &r) { diff --git a/inst/include/boost/accumulators/framework/depends_on.hpp b/inst/include/boost/accumulators/framework/depends_on.hpp index dd2b637b5..e0036ac73 100644 --- a/inst/include/boost/accumulators/framework/depends_on.hpp +++ b/inst/include/boost/accumulators/framework/depends_on.hpp @@ -321,6 +321,12 @@ namespace boost { namespace accumulators { } + accumulator_wrapper& operator=(accumulator_wrapper const &that) + { + *static_cast(this) = *static_cast(&that); + return *this; + } + template accumulator_wrapper(Args const &args) : Accumulator(args) diff --git a/inst/include/boost/accumulators/statistics/count.hpp b/inst/include/boost/accumulators/statistics/count.hpp index b83435a30..2bd09a974 100644 --- a/inst/include/boost/accumulators/statistics/count.hpp +++ b/inst/include/boost/accumulators/statistics/count.hpp @@ -45,8 +45,8 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & cnt; } diff --git a/inst/include/boost/accumulators/statistics/extended_p_square_quantile.hpp b/inst/include/boost/accumulators/statistics/extended_p_square_quantile.hpp index f57304cd0..a4ac3cd6c 100644 --- a/inst/include/boost/accumulators/statistics/extended_p_square_quantile.hpp +++ b/inst/include/boost/accumulators/statistics/extended_p_square_quantile.hpp @@ -76,6 +76,7 @@ namespace impl boost::begin(args[extended_p_square_probabilities]) , boost::end(args[extended_p_square_probabilities]) ) + , probability() { } diff --git a/inst/include/boost/accumulators/statistics/max.hpp b/inst/include/boost/accumulators/statistics/max.hpp index 15033e6da..4cc8c559e 100644 --- a/inst/include/boost/accumulators/statistics/max.hpp +++ b/inst/include/boost/accumulators/statistics/max.hpp @@ -50,8 +50,8 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & max_; } diff --git a/inst/include/boost/accumulators/statistics/mean.hpp b/inst/include/boost/accumulators/statistics/mean.hpp index c6df176b7..699fad7a1 100644 --- a/inst/include/boost/accumulators/statistics/mean.hpp +++ b/inst/include/boost/accumulators/statistics/mean.hpp @@ -44,7 +44,7 @@ namespace impl // serialization is done by accumulators it depends on template - void serialize(Archive & ar, const unsigned int file_version) {} + void serialize(Archive & /* ar */, const unsigned int /* file_version */) {} }; template @@ -76,8 +76,8 @@ namespace impl } template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & mean; } diff --git a/inst/include/boost/accumulators/statistics/min.hpp b/inst/include/boost/accumulators/statistics/min.hpp index bf30b79e3..2cbe2775d 100644 --- a/inst/include/boost/accumulators/statistics/min.hpp +++ b/inst/include/boost/accumulators/statistics/min.hpp @@ -50,8 +50,8 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & min_; } diff --git a/inst/include/boost/accumulators/statistics/moment.hpp b/inst/include/boost/accumulators/statistics/moment.hpp index 9ba1e4caa..aeca6a985 100644 --- a/inst/include/boost/accumulators/statistics/moment.hpp +++ b/inst/include/boost/accumulators/statistics/moment.hpp @@ -77,8 +77,8 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & sum; } diff --git a/inst/include/boost/accumulators/statistics/sum.hpp b/inst/include/boost/accumulators/statistics/sum.hpp index 7e507ccc2..c8beb55bf 100644 --- a/inst/include/boost/accumulators/statistics/sum.hpp +++ b/inst/include/boost/accumulators/statistics/sum.hpp @@ -52,8 +52,8 @@ namespace impl } template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & sum; } diff --git a/inst/include/boost/accumulators/statistics/tail.hpp b/inst/include/boost/accumulators/statistics/tail.hpp index 154a30cc2..40dab3718 100644 --- a/inst/include/boost/accumulators/statistics/tail.hpp +++ b/inst/include/boost/accumulators/statistics/tail.hpp @@ -88,7 +88,7 @@ namespace detail } private: - stat_assign_visitor &operator =(stat_assign_visitor const &); + BOOST_DELETED_FUNCTION(stat_assign_visitor &operator =(stat_assign_visitor const &)) Args const &args; std::size_t index; }; @@ -264,7 +264,7 @@ namespace impl } private: - indirect_cmp &operator =(indirect_cmp const &); + BOOST_DELETED_FUNCTION(indirect_cmp &operator =(indirect_cmp const &)) std::vector const &samples; }; diff --git a/inst/include/boost/accumulators/statistics/variance.hpp b/inst/include/boost/accumulators/statistics/variance.hpp index 9db858d2f..f760c3e1a 100644 --- a/inst/include/boost/accumulators/statistics/variance.hpp +++ b/inst/include/boost/accumulators/statistics/variance.hpp @@ -56,7 +56,7 @@ namespace impl // serialization is done by accumulators it depends on template - void serialize(Archive & ar, const unsigned int file_version) {} + void serialize(Archive & /* ar */, const unsigned int /* file_version */) {} }; //! Iterative calculation of variance. @@ -119,8 +119,8 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) - { + void serialize(Archive & ar, const unsigned int /* file_version */) + { ar & variance; } diff --git a/inst/include/boost/accumulators/statistics/weighted_mean.hpp b/inst/include/boost/accumulators/statistics/weighted_mean.hpp index 1ddce8dd5..3214af6fc 100644 --- a/inst/include/boost/accumulators/statistics/weighted_mean.hpp +++ b/inst/include/boost/accumulators/statistics/weighted_mean.hpp @@ -99,7 +99,7 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) + void serialize(Archive & ar, const unsigned int /* file_version */) { ar & mean; } diff --git a/inst/include/boost/accumulators/statistics/weighted_sum.hpp b/inst/include/boost/accumulators/statistics/weighted_sum.hpp index 41091f876..7e5167743 100644 --- a/inst/include/boost/accumulators/statistics/weighted_sum.hpp +++ b/inst/include/boost/accumulators/statistics/weighted_sum.hpp @@ -57,7 +57,7 @@ namespace impl // make this accumulator serializeable template - void serialize(Archive & ar, const unsigned int file_version) + void serialize(Archive & ar, const unsigned int /* file_version */) { ar & weighted_sum_; } diff --git a/inst/include/boost/algorithm/gather.hpp b/inst/include/boost/algorithm/gather.hpp index e777f8bd1..00f173397 100644 --- a/inst/include/boost/algorithm/gather.hpp +++ b/inst/include/boost/algorithm/gather.hpp @@ -1,4 +1,4 @@ -/* +/* Copyright 2008 Adobe Systems Incorporated Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -84,7 +84,7 @@ namespace boost { namespace algorithm { template < typename BidirectionalIterator, // models BidirectionalIterator typename Pred> // models UnaryPredicate -std::pair gather +std::pair gather ( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred ) { // The first call partitions everything up to (but not including) the pivot element, @@ -106,11 +106,11 @@ template < typename BidirectionalRange, // typename Pred> // Pred models UnaryPredicate std::pair< - typename boost::range_iterator::type, - typename boost::range_iterator::type> + typename boost::range_iterator::type, + typename boost::range_iterator::type> gather ( - const BidirectionalRange &range, - typename boost::range_iterator::type pivot, + BidirectionalRange &range, + typename boost::range_iterator::type pivot, Pred pred ) { return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred ); diff --git a/inst/include/boost/any.hpp b/inst/include/boost/any.hpp index 9d2e92141..f7812eef9 100644 --- a/inst/include/boost/any.hpp +++ b/inst/include/boost/any.hpp @@ -8,6 +8,9 @@ # pragma once #endif +/// \file boost/any.hpp +/// \brief \copybrief boost::any + // what: variant type boost::any // who: contributed by Kevlin Henney, // with features contributed and bugs found by @@ -17,78 +20,102 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include +#include + +#include // for std::addressof +#include namespace boost { + /// \brief A class whose instances can hold instances of any + /// type that satisfies \forcedlink{ValueType} requirements. class any { - public: // structors + public: - BOOST_CONSTEXPR any() BOOST_NOEXCEPT + /// \post this->empty() is true. + constexpr any() noexcept : content(0) { } + /// Makes a copy of `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value`. + /// + /// \throws std::bad_alloc or any exceptions arising from the copy + /// constructor of the contained type. template any(const ValueType & value) : content(new holder< - BOOST_DEDUCED_TYPENAME remove_cv::type>::type + typename std::remove_cv::type>::type >(value)) { - BOOST_STATIC_ASSERT_MSG( + static_assert( !anys::detail::is_basic_any::value, "boost::any shall not be constructed from boost::anys::basic_any" ); } + /// Copy constructor that copies content of + /// `other` into new instance, so that any content + /// is equivalent in both type and value to the content of + /// `other`, or empty if `other` is empty. + /// + /// \throws May fail with a `std::bad_alloc` + /// exception or any exceptions arising from the copy + /// constructor of the contained type. any(const any & other) : content(other.content ? other.content->clone() : 0) { } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - // Move constructor - any(any&& other) BOOST_NOEXCEPT + /// Move constructor that moves content of + /// `other` into new instance and leaves `other` empty. + /// + /// \post other->empty() is true + /// \throws Nothing. + any(any&& other) noexcept : content(other.content) { other.content = 0; } - // Perfect forwarding of ValueType + /// Forwards `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value` before the forward. + /// + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template any(ValueType&& value - , typename boost::disable_if >::type* = 0 // disable if value has type `any&` - , typename boost::disable_if >::type* = 0) // disable if value has type `const ValueType&&` - : content(new holder< typename decay::type >(static_cast(value))) + , typename std::enable_if::value >::type* = 0 // disable if value has type `any&` + , typename std::enable_if::value >::type* = 0) // disable if value has type `const ValueType&&` + : content(new holder< typename std::decay::type >(std::forward(value))) { - BOOST_STATIC_ASSERT_MSG( - !anys::detail::is_basic_any::type>::value, + static_assert( + !anys::detail::is_basic_any::type>::value, "boost::any shall not be constructed from boost::anys::basic_any" ); } -#endif - ~any() BOOST_NOEXCEPT + /// Releases any and all resources used in management of instance. + /// + /// \throws Nothing. + ~any() noexcept { delete content; } public: // modifiers - any & swap(any & rhs) BOOST_NOEXCEPT + /// Exchange of the contents of `*this` and `rhs`. + /// + /// \returns `*this` + /// \throws Nothing. + any & swap(any & rhs) noexcept { placeholder* tmp = content; content = rhs.content; @@ -96,97 +123,92 @@ namespace boost return *this; } - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - any & operator=(const ValueType & rhs) - { - BOOST_STATIC_ASSERT_MSG( - !anys::detail::is_basic_any::value, - "boost::anys::basic_any shall not be assigned into boost::any" - ); - any(rhs).swap(*this); - return *this; - } - - any & operator=(any rhs) - { - rhs.swap(*this); - return *this; - } - -#else + /// Copies content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs`, or empty if `rhs.empty()`. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. any & operator=(const any& rhs) { any(rhs).swap(*this); return *this; } - // move assignment - any & operator=(any&& rhs) BOOST_NOEXCEPT + /// Moves content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs` before move, or empty if + /// `rhs.empty()`. + /// + /// \post `rhs->empty()` is true + /// \throws Nothing. + any & operator=(any&& rhs) noexcept { rhs.swap(*this); any().swap(rhs); return *this; } - // Perfect forwarding of ValueType + /// Forwards `rhs`, + /// discarding previous content, so that the new content of is + /// equivalent in both type and value to + /// `rhs` before forward. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the move or copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. template any & operator=(ValueType&& rhs) { - BOOST_STATIC_ASSERT_MSG( - !anys::detail::is_basic_any::type>::value, + static_assert( + !anys::detail::is_basic_any::type>::value, "boost::anys::basic_any shall not be assigned into boost::any" ); - any(static_cast(rhs)).swap(*this); + any(std::forward(rhs)).swap(*this); return *this; } -#endif public: // queries - bool empty() const BOOST_NOEXCEPT + /// \returns `true` if instance is empty, otherwise `false`. + /// \throws Nothing. + bool empty() const noexcept { return !content; } - void clear() BOOST_NOEXCEPT + /// \post this->empty() is true + void clear() noexcept { any().swap(*this); } - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT + /// \returns the `typeid` of the + /// contained value if instance is non-empty, otherwise + /// `typeid(void)`. + /// + /// Useful for querying against types known either at compile time or + /// only at runtime. + const boost::typeindex::type_info& type() const noexcept { return content ? content->type() : boost::typeindex::type_id().type_info(); } -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS private: // types -#else - public: // types (public so any_cast can be non-friend) -#endif - - class BOOST_SYMBOL_VISIBLE placeholder + /// @cond + class BOOST_SYMBOL_VISIBLE placeholder: public boost::anys::detail::placeholder { - public: // structors - - virtual ~placeholder() - { - } - - public: // queries - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; - + public: virtual placeholder * clone() const = 0; - }; template - class holder -#ifndef BOOST_NO_CXX11_FINAL - final -#endif + class holder final : public placeholder { public: // structors @@ -196,15 +218,14 @@ namespace boost { } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES holder(ValueType&& value) : held(static_cast< ValueType&& >(value)) { } -#endif + public: // queries - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT BOOST_OVERRIDE + const boost::typeindex::type_info& type() const noexcept override { return boost::typeindex::type_id().type_info(); } @@ -222,54 +243,72 @@ namespace boost holder & operator=(const holder &); }; -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - private: // representation - - template - friend ValueType * any_cast(any *) BOOST_NOEXCEPT; - template - friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT; + friend ValueType * unsafe_any_cast(any *) noexcept; -#else - - public: // representation (public so any_cast can be non-friend) - -#endif + friend class boost::anys::unique_any; placeholder * content; - + /// @endcond }; - inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT + /// Exchange of the contents of `lhs` and `rhs`. + /// \throws Nothing. + inline void swap(any & lhs, any & rhs) noexcept { lhs.swap(rhs); } + /// @cond + + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template + inline ValueType * unsafe_any_cast(any * operand) noexcept + { + return std::addressof( + static_cast *>(operand->content)->held + ); + } + + template + inline const ValueType * unsafe_any_cast(const any * operand) noexcept + { + return boost::unsafe_any_cast(const_cast(operand)); + } + /// @endcond + + /// \returns Pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template - ValueType * any_cast(any * operand) BOOST_NOEXCEPT + ValueType * any_cast(any * operand) noexcept { return operand && operand->type() == boost::typeindex::type_id() - ? boost::addressof( - static_cast::type> *>(operand->content)->held - ) + ? boost::unsafe_any_cast::type>(operand) : 0; } + /// \returns Const pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template - inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT + inline const ValueType * any_cast(const any * operand) noexcept { - return any_cast(const_cast(operand)); + return boost::any_cast(const_cast(operand)); } + /// \returns ValueType stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified ValueType. template ValueType any_cast(any & operand) { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - + typedef typename std::remove_reference::type nonref; - nonref * result = any_cast(boost::addressof(operand)); + nonref * result = boost::any_cast(std::addressof(operand)); if(!result) boost::throw_exception(bad_any_cast()); @@ -277,10 +316,10 @@ namespace boost // `ValueType` is not a reference. Example: // `static_cast(*result);` // which is equal to `std::string(*result);` - typedef BOOST_DEDUCED_TYPENAME boost::conditional< - boost::is_reference::value, + typedef typename std::conditional< + std::is_reference::value, ValueType, - BOOST_DEDUCED_TYPENAME boost::add_reference::type + typename std::add_lvalue_reference::type >::type ref_type; #ifdef BOOST_MSVC @@ -293,49 +332,33 @@ namespace boost #endif } + /// \returns `ValueType` stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template inline ValueType any_cast(const any & operand) { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - return any_cast(const_cast(operand)); + typedef typename std::remove_reference::type nonref; + return boost::any_cast(const_cast(operand)); } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + /// \returns `ValueType` stored in `operand`, leaving the `operand` empty. + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template inline ValueType any_cast(any&& operand) { - BOOST_STATIC_ASSERT_MSG( - boost::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ - || boost::is_const< typename boost::remove_reference::type >::value, + static_assert( + std::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ + || std::is_const< typename std::remove_reference::type >::value, "boost::any_cast shall not be used for getting nonconst references to temporary objects" ); - return any_cast(operand); - } -#endif - - - // Note: The "unsafe" versions of any_cast are not part of the - // public interface and may be removed at any time. They are - // required where we know what type is stored in the any and can't - // use typeid() comparison, e.g., when our types may travel across - // different shared libraries. - template - inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT - { - return boost::addressof( - static_cast *>(operand->content)->held - ); - } - - template - inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT - { - return unsafe_any_cast(const_cast(operand)); + return boost::any_cast(operand); } } // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. -// Copyright Antony Polukhin, 2013-2022. +// Copyright Antony Polukhin, 2013-2023. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/inst/include/boost/any/bad_any_cast.hpp b/inst/include/boost/any/bad_any_cast.hpp index bba142da5..ed456021a 100644 --- a/inst/include/boost/any/bad_any_cast.hpp +++ b/inst/include/boost/any/bad_any_cast.hpp @@ -1,4 +1,4 @@ -// Copyright Antony Polukhin, 2020-2022. +// Copyright Antony Polukhin, 2020-2023. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -22,6 +22,8 @@ namespace boost { +/// The exception thrown in the event of a failed boost::any_cast of +/// an boost::any, boost::anys::basic_any or boost::anys::unique_any value. class BOOST_SYMBOL_VISIBLE bad_any_cast : #ifndef BOOST_NO_RTTI public std::bad_cast @@ -30,7 +32,7 @@ class BOOST_SYMBOL_VISIBLE bad_any_cast : #endif { public: - const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE + const char * what() const BOOST_NOEXCEPT_OR_NOTHROW override { return "boost::bad_any_cast: " "failed conversion using boost::any_cast"; diff --git a/inst/include/boost/any/basic_any.hpp b/inst/include/boost/any/basic_any.hpp index 980abed19..116cb4e1a 100644 --- a/inst/include/boost/any/basic_any.hpp +++ b/inst/include/boost/any/basic_any.hpp @@ -1,5 +1,5 @@ // Copyright Ruslan Arutyunyan, 2019-2021. -// Copyright Antony Polukhin, 2021-2022. +// Copyright Antony Polukhin, 2021-2023. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -15,37 +15,51 @@ # pragma once #endif +/// \file boost/any/basic_any.hpp +/// \brief \copybrief boost::anys::basic_any + #include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include + +#include // for std::addressof +#include + namespace boost { namespace anys { + /// \brief A class with customizable Small Object Optimization whose + /// instances can hold instances of any type that satisfies + /// \forcedlink{ValueType} requirements. Use boost::any instead if not sure. + /// + /// boost::anys::basic_any is the drop-in replacement for boost::any + /// that provides control over Small Object Optimization via + /// `OptimizeForSize` and `OptimizeForAlignment` template parameters. + /// + /// There are certain applications that require boost::any + /// functionality, do know the typical/maximal size of the stored object and + /// wish to avoid dynamic memory allocation overhead. For the convenience + /// such applications may create a typedef for boost::anys::basic_any + /// with the `OptimizeForSize` and `OptimizeForAlignment` template + /// parameters set to typical/maximal size and alignment of types + /// respectively. Memory allocation would be avoided for storing nothrow + /// move constructible types with size and alignment less than or + /// equal to the `OptimizeForSize` and `OptimizeForAlignment` values. + /// + /// Otherwise just use boost::any. template class basic_any { - BOOST_STATIC_ASSERT_MSG(OptimizeForSize > 0 && OptimizeForAlignment > 0, "Size and Align shall be positive values"); - BOOST_STATIC_ASSERT_MSG(OptimizeForSize >= OptimizeForAlignment, "Size shall non less than Align"); - BOOST_STATIC_ASSERT_MSG((OptimizeForAlignment & (OptimizeForAlignment - 1)) == 0, "Align shall be a power of 2"); - BOOST_STATIC_ASSERT_MSG(OptimizeForSize % OptimizeForAlignment == 0, "Size shall be multiple of alignment"); + static_assert(OptimizeForSize > 0 && OptimizeForAlignment > 0, "Size and Align shall be positive values"); + static_assert(OptimizeForSize >= OptimizeForAlignment, "Size shall non less than Align"); + static_assert((OptimizeForAlignment & (OptimizeForAlignment - 1)) == 0, "Align shall be a power of 2"); + static_assert(OptimizeForSize % OptimizeForAlignment == 0, "Size shall be multiple of alignment"); private: + /// @cond enum operation { Destroy, @@ -71,11 +85,7 @@ namespace anys { BOOST_ASSERT(!right->empty()); BOOST_ASSERT(right->type() == boost::typeindex::type_id()); ValueType* value = reinterpret_cast(&const_cast(right)->content.small_value); -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES new (&left.content.small_value) ValueType(std::move(*value)); -#else - new (&left.content.small_value) ValueType(*value); -#endif left.man = right->man; reinterpret_cast(&right->content.small_value)->~ValueType(); const_cast(right)->man = 0; @@ -95,10 +105,10 @@ namespace anys { BOOST_ASSERT(info); BOOST_ASSERT(!left.empty()); return boost::typeindex::type_id() == *info ? - reinterpret_cast::type *>(&left.content.small_value) : 0; + reinterpret_cast::type *>(&left.content.small_value) : 0; case UnsafeCast: BOOST_ASSERT(!left.empty()); - return reinterpret_cast::type *>(&left.content.small_value); + return reinterpret_cast::type *>(&left.content.small_value); case Typeinfo: return const_cast(static_cast(&boost::typeindex::type_id().type_info())); } @@ -137,10 +147,10 @@ namespace anys { BOOST_ASSERT(info); BOOST_ASSERT(!left.empty()); return boost::typeindex::type_id() == *info ? - static_cast::type *>(left.content.large_value) : 0; + static_cast::type *>(left.content.large_value) : 0; case UnsafeCast: BOOST_ASSERT(!left.empty()); - return reinterpret_cast::type *>(left.content.large_value); + return reinterpret_cast::type *>(left.content.large_value); case Typeinfo: return const_cast(static_cast(&boost::typeindex::type_id().type_info())); } @@ -149,72 +159,91 @@ namespace anys { } template - struct is_small_object : boost::integral_constant::value <= OptimizeForAlignment && - boost::is_nothrow_move_constructible::value> + struct is_small_object : std::integral_constant::value> {}; template - static void create(basic_any& any, const ValueType& value, boost::true_type) + static void create(basic_any& any, const ValueType& value, std::true_type) { - typedef typename boost::decay::type DecayedType; + typedef typename std::decay::type DecayedType; any.man = &small_manager; new (&any.content.small_value) ValueType(value); } template - static void create(basic_any& any, const ValueType& value, boost::false_type) + static void create(basic_any& any, const ValueType& value, std::false_type) { - typedef typename boost::decay::type DecayedType; + typedef typename std::decay::type DecayedType; any.man = &large_manager; any.content.large_value = new DecayedType(value); } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template - static void create(basic_any& any, ValueType&& value, boost::true_type) + static void create(basic_any& any, ValueType&& value, std::true_type) { - typedef typename boost::decay::type DecayedType; + typedef typename std::decay::type DecayedType; any.man = &small_manager; - new (&any.content.small_value) DecayedType(static_cast(value)); + new (&any.content.small_value) DecayedType(std::forward(value)); } template - static void create(basic_any& any, ValueType&& value, boost::false_type) + static void create(basic_any& any, ValueType&& value, std::false_type) { - typedef typename boost::decay::type DecayedType; + typedef typename std::decay::type DecayedType; any.man = &large_manager; - any.content.large_value = new DecayedType(static_cast(value)); + any.content.large_value = new DecayedType(std::forward(value)); } -#endif + /// @endcond + public: // non-type template parameters accessors - static BOOST_CONSTEXPR_OR_CONST std::size_t buffer_size = OptimizeForSize; - static BOOST_CONSTEXPR_OR_CONST std::size_t buffer_align = OptimizeForAlignment; + static constexpr std::size_t buffer_size = OptimizeForSize; + static constexpr std::size_t buffer_align = OptimizeForAlignment; public: // structors - BOOST_CONSTEXPR basic_any() BOOST_NOEXCEPT + /// \post this->empty() is true. + constexpr basic_any() noexcept : man(0), content() { } + /// Makes a copy of `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value`. + /// + /// Does not dynamically allocate if `ValueType` is nothrow + /// move constructible and `sizeof(value) <= OptimizeForSize` and + /// `alignof(value) <= OptimizeForAlignment`. + /// + /// \throws std::bad_alloc or any exceptions arising from the copy + /// constructor of the contained type. template basic_any(const ValueType & value) : man(0), content() { - BOOST_STATIC_ASSERT_MSG( - !(boost::is_same::value), + static_assert( + !std::is_same::value, "boost::anys::basic_any shall not be constructed from boost::any" ); - BOOST_STATIC_ASSERT_MSG( + static_assert( !anys::detail::is_basic_any::value, "boost::anys::basic_any shall not be constructed from boost::anys::basic_any" ); create(*this, value, is_small_object()); } + /// Copy constructor that copies content of + /// `other` into new instance, so that any content + /// is equivalent in both type and value to the content of + /// `other`, or empty if `other` is empty. + /// + /// \throws May fail with a `std::bad_alloc` + /// exception or any exceptions arising from the copy + /// constructor of the contained type. basic_any(const basic_any & other) : man(0), content() { @@ -224,9 +253,12 @@ namespace anys { } } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - // Move constructor - basic_any(basic_any&& other) BOOST_NOEXCEPT + /// Move constructor that moves content of + /// `other` into new instance and leaves `other` empty. + /// + /// \post other->empty() is true + /// \throws Nothing. + basic_any(basic_any&& other) noexcept : man(0), content() { if (other.man) @@ -235,27 +267,38 @@ namespace anys { } } - // Perfect forwarding of ValueType + /// Forwards `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value` before the forward. + /// + /// Does not dynamically allocate if `ValueType` is nothrow + /// move constructible and `sizeof(value) <= OptimizeForSize` and + /// `alignof(value) <= OptimizeForAlignment`. + /// + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template basic_any(ValueType&& value - , typename boost::disable_if >::type* = 0 // disable if value has type `basic_any&` - , typename boost::disable_if >::type* = 0) // disable if value has type `const ValueType&&` + , typename std::enable_if::value >::type* = 0 // disable if value has type `basic_any&` + , typename std::enable_if::value >::type* = 0) // disable if value has type `const ValueType&&` : man(0), content() { - typedef typename boost::decay::type DecayedType; - BOOST_STATIC_ASSERT_MSG( - !(boost::is_same::value), + typedef typename std::decay::type DecayedType; + static_assert( + !std::is_same::value, "boost::anys::basic_any shall not be constructed from boost::any" ); - BOOST_STATIC_ASSERT_MSG( + static_assert( !anys::detail::is_basic_any::value, "boost::anys::basic_any shall not be constructed from boost::anys::basic_any" ); create(*this, static_cast(value), is_small_object()); } -#endif - ~basic_any() BOOST_NOEXCEPT + /// Releases any and all resources used in management of instance. + /// + /// \throws Nothing. + ~basic_any() noexcept { if (man) { @@ -265,7 +308,11 @@ namespace anys { public: // modifiers - basic_any & swap(basic_any & rhs) BOOST_NOEXCEPT + /// Exchange of the contents of `*this` and `rhs`. + /// + /// \returns `*this` + /// \throws Nothing. + basic_any & swap(basic_any & rhs) noexcept { if (this == &rhs) { @@ -290,74 +337,86 @@ namespace anys { return *this; } - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - basic_any & operator=(const ValueType & rhs) - { - BOOST_STATIC_ASSERT_MSG( - !(boost::is_same::value), - "boost::any shall not be assigned into boost::anys::basic_any" - ); - BOOST_STATIC_ASSERT_MSG( - !anys::detail::is_basic_any::value, - "boost::anys::basic_any shall not be assigned into boost::anys::basic_any" - ); - basic_any(rhs).swap(*this); - return *this; - } - - basic_any & operator=(basic_any rhs) - { - rhs.swap(*this); - return *this; - } - -#else + /// Copies content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs`, or empty if `rhs.empty()`. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. basic_any & operator=(const basic_any& rhs) { basic_any(rhs).swap(*this); return *this; } - // move assignment - basic_any & operator=(basic_any&& rhs) BOOST_NOEXCEPT + /// Moves content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs` before move, or empty if + /// `rhs.empty()`. + /// + /// \post `rhs->empty()` is true + /// \throws Nothing. + basic_any & operator=(basic_any&& rhs) noexcept { rhs.swap(*this); basic_any().swap(rhs); return *this; } - // Perfect forwarding of ValueType + /// Forwards `rhs`, + /// discarding previous content, so that the new content of is + /// equivalent in both type and value to + /// `rhs` before forward. + /// + /// Does not dynamically allocate if `ValueType` is nothrow + /// move constructible and `sizeof(value) <= OptimizeForSize` and + /// `alignof(value) <= OptimizeForAlignment`. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the move or copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. template basic_any & operator=(ValueType&& rhs) { - typedef typename boost::decay::type DecayedType; - BOOST_STATIC_ASSERT_MSG( - !(boost::is_same::value), + typedef typename std::decay::type DecayedType; + static_assert( + !std::is_same::value, "boost::any shall not be assigned into boost::anys::basic_any" ); - BOOST_STATIC_ASSERT_MSG( - (!anys::detail::is_basic_any::value || boost::is_same::value), + static_assert( + !anys::detail::is_basic_any::value || std::is_same::value, "boost::anys::basic_any shall not be assigned into boost::anys::basic_any" ); - basic_any(static_cast(rhs)).swap(*this); + basic_any(std::forward(rhs)).swap(*this); return *this; } -#endif public: // queries - bool empty() const BOOST_NOEXCEPT + /// \returns `true` if instance is empty, otherwise `false`. + /// \throws Nothing. + bool empty() const noexcept { return !man; } - void clear() BOOST_NOEXCEPT + /// \post this->empty() is true + void clear() noexcept { basic_any().swap(*this); } + /// \returns the `typeid` of the + /// contained value if instance is non-empty, otherwise + /// `typeid(void)`. + /// + /// Useful for querying against types known either at compile time or + /// only at runtime. const boost::typeindex::type_info& type() const BOOST_NOEXCEPT { return man @@ -366,12 +425,12 @@ namespace anys { } private: // representation - + /// @cond template - friend ValueType * any_cast(basic_any *) BOOST_NOEXCEPT; + friend ValueType * any_cast(basic_any *) noexcept; template - friend ValueType * unsafe_any_cast(basic_any *) BOOST_NOEXCEPT; + friend ValueType * unsafe_any_cast(basic_any *) noexcept; typedef void*(*manager)(operation op, basic_any& left, const basic_any* right, const boost::typeindex::type_info* info); @@ -379,36 +438,46 @@ namespace anys { union content { void * large_value; - typename boost::aligned_storage::type small_value; + alignas(OptimizeForAlignment) unsigned char small_value[OptimizeForSize]; } content; + /// @endcond }; + /// Exchange of the contents of `lhs` and `rhs`. + /// \throws Nothing. template - void swap(basic_any& lhs, basic_any& rhs) BOOST_NOEXCEPT + void swap(basic_any& lhs, basic_any& rhs) noexcept { lhs.swap(rhs); } + /// \returns Pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template - ValueType * any_cast(basic_any * operand) BOOST_NOEXCEPT + ValueType * any_cast(basic_any * operand) noexcept { return operand->man ? - static_cast::type *>(operand->man(basic_any::AnyCast, *operand, 0, &boost::typeindex::type_id().type_info())) + static_cast::type *>(operand->man(basic_any::AnyCast, *operand, 0, &boost::typeindex::type_id().type_info())) : 0; } + /// \returns Const pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template - inline const ValueType * any_cast(const basic_any * operand) BOOST_NOEXCEPT + inline const ValueType * any_cast(const basic_any * operand) noexcept { - return any_cast(const_cast *>(operand)); + return boost::anys::any_cast(const_cast *>(operand)); } + /// \returns ValueType stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified ValueType. template ValueType any_cast(basic_any & operand) { - typedef typename remove_reference::type nonref; + typedef typename std::remove_reference::type nonref; - nonref * result = any_cast(boost::addressof(operand)); + nonref * result = boost::anys::any_cast(std::addressof(operand)); if(!result) boost::throw_exception(bad_any_cast()); @@ -416,10 +485,10 @@ namespace anys { // `ValueType` is not a reference. Example: // `static_cast(*result);` // which is equal to `std::string(*result);` - typedef typename boost::conditional< - boost::is_reference::value, + typedef typename std::conditional< + std::is_reference::value, ValueType, - typename boost::add_reference::type + typename std::add_lvalue_reference::type >::type ref_type; #ifdef BOOST_MSVC @@ -432,43 +501,50 @@ namespace anys { #endif } + /// \returns `ValueType` stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template inline ValueType any_cast(const basic_any & operand) { - typedef typename remove_reference::type nonref; - return any_cast(const_cast &>(operand)); + typedef typename std::remove_reference::type nonref; + return boost::anys::any_cast(const_cast &>(operand)); } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + /// \returns `ValueType` stored in `operand`, leaving the `operand` empty. + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template inline ValueType any_cast(basic_any&& operand) { - BOOST_STATIC_ASSERT_MSG( - boost::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ - || boost::is_const< typename boost::remove_reference::type >::value, + static_assert( + std::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ + || std::is_const< typename std::remove_reference::type >::value, "boost::any_cast shall not be used for getting nonconst references to temporary objects" ); - return any_cast(operand); + return boost::anys::any_cast(operand); } -#endif + /// @cond + // Note: The "unsafe" versions of any_cast are not part of the // public interface and may be removed at any time. They are // required where we know what type is stored in the any and can't // use typeid() comparison, e.g., when our types may travel across // different shared libraries. template - inline ValueType * unsafe_any_cast(basic_any * operand) BOOST_NOEXCEPT + inline ValueType * unsafe_any_cast(basic_any * operand) noexcept { return static_cast(operand->man(basic_any::UnsafeCast, *operand, 0, 0)); } template - inline const ValueType * unsafe_any_cast(const basic_any * operand) BOOST_NOEXCEPT + inline const ValueType * unsafe_any_cast(const basic_any * operand) noexcept { - return unsafe_any_cast(const_cast *>(operand)); + return boost::anys::unsafe_any_cast(const_cast *>(operand)); } + /// @endcond } // namespace anys diff --git a/inst/include/boost/any/detail/placeholder.hpp b/inst/include/boost/any/detail/placeholder.hpp new file mode 100644 index 000000000..360d78cb0 --- /dev/null +++ b/inst/include/boost/any/detail/placeholder.hpp @@ -0,0 +1,33 @@ +// Copyright Antony Polukhin, 2021-2023. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP +#define BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP + +#include +#ifdef BOOST_HAS_PRAGMA_ONCE +# pragma once +#endif + +#include + +/// @cond +namespace boost { +namespace anys { +namespace detail { + +class BOOST_SYMBOL_VISIBLE placeholder { +public: + virtual ~placeholder() {} + virtual const boost::typeindex::type_info& type() const noexcept = 0; +}; + +} // namespace detail +} // namespace anys +} // namespace boost +/// @endcond + +#endif // #ifndef BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP diff --git a/inst/include/boost/any/fwd.hpp b/inst/include/boost/any/fwd.hpp index 6905b2644..752f3acef 100644 --- a/inst/include/boost/any/fwd.hpp +++ b/inst/include/boost/any/fwd.hpp @@ -1,4 +1,4 @@ -// Copyright Antony Polukhin, 2021-2022. +// Copyright Antony Polukhin, 2021-2023. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -13,28 +13,43 @@ # pragma once #endif - #include +/// \file boost/any/fwd.hpp +/// \brief Forward declarations of Boost.Any library types. +/// @cond namespace boost { class any; namespace anys { -template::value> +class unique_any; + +template class basic_any; namespace detail { - template - struct is_basic_any: public false_type {}; + template + struct is_basic_any: public std::false_type {}; template - struct is_basic_any > : public true_type {}; + struct is_basic_any > : public std::true_type {}; + + template + struct is_some_any: public is_basic_any {}; + + template <> + struct is_some_any: public std::true_type {}; + + template <> + struct is_some_any: public std::true_type {}; + } // namespace detail } // namespace anys } // namespace boost +/// @endcond #endif // #ifndef BOOST_ANY_ANYS_FWD_HPP diff --git a/inst/include/boost/any/unique_any.hpp b/inst/include/boost/any/unique_any.hpp index a56dd6c8c..9f4f41c17 100644 --- a/inst/include/boost/any/unique_any.hpp +++ b/inst/include/boost/any/unique_any.hpp @@ -1,4 +1,4 @@ -// Copyright Antony Polukhin, 2020-2022. +// Copyright Antony Polukhin, 2020-2023. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -14,32 +14,23 @@ # pragma once #endif -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES -#error Header requires C++11 compatible compiler with move semantics -#endif - -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS -#error Header requires C++11 compatible compiler with defaulted functions -#endif - -#ifdef BOOST_NO_CXX11_SMART_PTR -#error Header requires C++11 compatible standard library with std::unique_ptr -#endif -#include - -#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST -#include -#endif +/// \file boost/any/unique_any.hpp +/// \brief \copybrief boost::anys::unique_any +#include // for std::unique_ptr #include +#include +#include #include +#include -#include -#include +#include +#include namespace boost { namespace anys { +/// Helper type for providing emplacement type to the constructor. template struct in_place_type_t { @@ -50,40 +41,104 @@ template constexpr in_place_type_t in_place_type{}; #endif +/// \brief A class whose instances can hold instances of any +/// type (including non-copyable and non-movable types). class unique_any { public: + /// \post this->has_value() is false. + constexpr unique_any() noexcept = default; + + /// Move constructor that moves content of + /// `other` into new instance and leaves `other` empty. + /// + /// \post other->has_value() is false. + /// \throws Nothing. + unique_any(unique_any&& other) noexcept = default; + + /// Forwards `value`, so + /// that the content of the new instance has type `std::decay_t` + /// and value is the `value` before the forward. + /// + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. + template + unique_any(T&& value, typename std::enable_if::value>::type* = nullptr) + : content(new holder< typename std::decay::type >(std::forward(value))) + { + static_assert( + !boost::anys::detail::is_basic_any< typename std::decay::type >::value, + "boost::anys::unique_any could not be constructed from boost::anys::basic_any." + ); - BOOST_CONSTEXPR unique_any() BOOST_NOEXCEPT = default; + static_assert( + !std::is_same::type >::value, + "boost::anys::unique_any could not be copied, only moved." + ); - unique_any(unique_any&& other) BOOST_NOEXCEPT = default; + static_assert( + !std::is_same::type >::value, + "boost::anys::unique_any could be constructed from an rvalue of boost::any, " + "not a lvalue." + ); + } - // Perfect forwarding of T - template - unique_any(T&& value - , typename boost::disable_if >::type* = 0 // disable if value has type `unique_any&` - , typename boost::disable_if >::type* = 0) // disable if value has type `const T&&` - : content(new holder< typename boost::decay::type >(std::forward(value))) + /// Moves the content of `boost::any` into *this. + /// + /// \throws Nothing. + /// \post `value.empty()` is true. + template + unique_any(BoostAny&& value, typename std::enable_if::value>::type* = nullptr) noexcept { + content.reset(value.content); + value.content = nullptr; } + /// Inplace constructs `T` from forwarded `args...`, + /// so that the content of `*this` is equivalent + /// in type to `std::decay_t`. + /// + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template explicit unique_any(in_place_type_t, Args&&... args) - : content(new holder::type>(std::forward(args)...)) + : content(new holder::type>(std::forward(args)...)) { } -#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + /// Inplace constructs `T` from `li` and forwarded `args...`, + /// so that the initial content of `*this` is equivalent + /// in type to `std::decay_t`. + /// + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template explicit unique_any(in_place_type_t, std::initializer_list il, Args&&... args) - : content(new holder::type>(il, std::forward(args)...)) + : content(new holder::type>(il, std::forward(args)...)) { } -#endif - - ~unique_any() BOOST_NOEXCEPT = default; - - unique_any & operator=(unique_any&& rhs) BOOST_NOEXCEPT = default; + /// Releases any and all resources used in management of instance. + /// + /// \throws Nothing. + ~unique_any() noexcept = default; + + /// Moves content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of rhs before move, or empty if `rhs.empty()`. + /// + /// \post `rhs->empty()` is true + /// \throws Nothing. + unique_any & operator=(unique_any&& rhs) noexcept = default; + + /// Forwards `rhs`, + /// discarding previous content, so that the new content of is + /// equivalent in both type and value to `rhs` before forward. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the move or copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. template unique_any & operator=(T&& rhs) { @@ -91,124 +146,157 @@ class unique_any { return *this; } + /// Inplace constructs `T` from forwarded `args...`, discarding previous + /// content, so that the content of `*this` is equivalent + /// in type to `std::decay_t`. + /// + /// \returns reference to the content of `*this`. + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template - typename boost::decay::type& emplace(Args&&... args) { - content = std::unique_ptr( - new holder::type>(std::forward(args)...) - ); + typename std::decay::type& emplace(Args&&... args) { + auto* raw_ptr = new holder::type>(std::forward(args)...); + content = std::unique_ptr(raw_ptr); + return raw_ptr->held; } -#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + /// Inplace constructs `T` from `li` and forwarded `args...`, discarding + /// previous content, so that the content of `*this` is equivalent + /// in type to `std::decay_t`. + /// + /// \returns reference to the content of `*this`. + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template - typename boost::decay::type& emplace(initializer_list il, Args&&... args) { - content = std::unique_ptr( - new holder::type>(il, std::forward(args)...) - ); + typename std::decay::type& emplace(std::initializer_list il, Args&&... args) { + auto* raw_ptr = new holder::type>(il, std::forward(args)...); + content = std::unique_ptr(raw_ptr); + return raw_ptr->held; } -#endif - void reset() BOOST_NOEXCEPT + /// \post this->has_value() is false. + void reset() noexcept { content.reset(); } - unique_any& swap(unique_any& rhs) BOOST_NOEXCEPT + /// Exchange of the contents of `*this` and `rhs`. + /// + /// \returns `*this` + /// \throws Nothing. + void swap(unique_any& rhs) noexcept { content.swap(rhs.content); - return *this; } - - bool has_value() const BOOST_NOEXCEPT + /// \returns `true` if instance is not empty, otherwise `false`. + /// \throws Nothing. + bool has_value() const noexcept { - return !content; + return !!content; } - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT + /// \returns the `typeid` of the + /// contained value if instance is non-empty, otherwise + /// `typeid(void)`. + /// + /// Useful for querying against types known either at compile time or + /// only at runtime. + const boost::typeindex::type_info& type() const noexcept { return content ? content->type() : boost::typeindex::type_id().type_info(); } private: // types - class BOOST_SYMBOL_VISIBLE placeholder - { - virtual ~placeholder() - { - } - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; - - }; - + /// @cond template - class holder BOOST_FINAL: public placeholder + class holder final: public boost::anys::detail::placeholder { - public: // structors - + public: template holder(Args&&... args) : held(std::forward(args)...) { } -#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST template holder(std::initializer_list il, Args&&... args) : held(il, std::forward(args)...) { } -#endif - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT BOOST_OVERRIDE + const boost::typeindex::type_info& type() const noexcept override { return boost::typeindex::type_id().type_info(); } - public: // representation - + public: T held; }; - private: // representation - template - friend T * any_cast(unique_any *) BOOST_NOEXCEPT; + friend T * unsafe_any_cast(unique_any *) noexcept; - template - friend T * unsafe_any_cast(unique_any *) BOOST_NOEXCEPT; - - std::unique_ptr content; + std::unique_ptr content; + /// @endcond }; -inline void swap(unique_any & lhs, unique_any & rhs) BOOST_NOEXCEPT +/// Exchange of the contents of `lhs` and `rhs`. +/// \throws Nothing. +inline void swap(unique_any & lhs, unique_any & rhs) noexcept { lhs.swap(rhs); } +/// @cond + +// Note: The "unsafe" versions of any_cast are not part of the +// public interface and may be removed at any time. They are +// required where we know what type is stored in the any and can't +// use typeid() comparison, e.g., when our types may travel across +// different shared libraries. +template +inline T * unsafe_any_cast(unique_any * operand) noexcept +{ + return std::addressof( + static_cast&>(*operand->content).held + ); +} + +template +inline const T * unsafe_any_cast(const unique_any * operand) noexcept +{ + return anys::unsafe_any_cast(const_cast(operand)); +} +/// @endcond + +/// \returns Pointer to a `T` stored in `operand`, nullptr if +/// `operand` does not contain specified `T`. template -T * any_cast(unique_any * operand) BOOST_NOEXCEPT +T * any_cast(unique_any * operand) noexcept { return operand && operand->type() == boost::typeindex::type_id() - ? boost::addressof( - static_cast::type>&>(*operand->content).held - ) - : 0; + ? anys::unsafe_any_cast::type>(operand) + : nullptr; } +/// \returns Const pointer to a `T` stored in `operand`, nullptr if +/// `operand` does not contain specified `T`. template -inline const T * any_cast(const unique_any * operand) BOOST_NOEXCEPT +inline const T * any_cast(const unique_any * operand) noexcept { - return any_cast(const_cast(operand)); + return anys::any_cast(const_cast(operand)); } +/// \returns `T` stored in `operand` +/// \throws boost::bad_any_cast if `operand` does not contain specified `T`. template T any_cast(unique_any & operand) { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + typedef typename std::remove_reference::type nonref; - - nonref * result = any_cast(boost::addressof(operand)); + nonref * result = anys::any_cast(std::addressof(operand)); if(!result) boost::throw_exception(bad_any_cast()); @@ -216,10 +304,10 @@ T any_cast(unique_any & operand) // `T` is not a reference. Example: // `static_cast(*result);` // which is equal to `std::string(*result);` - typedef BOOST_DEDUCED_TYPENAME boost::conditional< - boost::is_reference::value, + typedef typename std::conditional< + std::is_reference::value, T, - BOOST_DEDUCED_TYPENAME boost::add_reference::type + T& >::type ref_type; #ifdef BOOST_MSVC @@ -232,44 +320,26 @@ T any_cast(unique_any & operand) #endif } +/// \returns `T` stored in `operand` +/// \throws boost::bad_any_cast if `operand` does not contain specified `T`. template inline T any_cast(const unique_any & operand) { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - return any_cast(const_cast(operand)); + typedef typename std::remove_reference::type nonref; + return anys::any_cast(const_cast(operand)); } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +/// \returns `T` stored in `operand` +/// \throws boost::bad_any_cast if `operand` does not contain specified `T`. template inline T any_cast(unique_any&& operand) { - BOOST_STATIC_ASSERT_MSG( - boost::is_rvalue_reference::value /*true if T is rvalue or just a value*/ - || boost::is_const< typename boost::remove_reference::type >::value, + static_assert( + std::is_rvalue_reference::value /*true if T is rvalue or just a value*/ + || std::is_const< typename std::remove_reference::type >::value, "boost::any_cast shall not be used for getting nonconst references to temporary objects" ); - return any_cast(operand); -} -#endif - - -// Note: The "unsafe" versions of any_cast are not part of the -// public interface and may be removed at any time. They are -// required where we know what type is stored in the any and can't -// use typeid() comparison, e.g., when our types may travel across -// different shared libraries. -template -inline T * unsafe_any_cast(unique_any * operand) BOOST_NOEXCEPT -{ - return boost::addressof( - static_cast&>(*operand->content)->held - ); -} - -template -inline const T * unsafe_any_cast(const unique_any * operand) BOOST_NOEXCEPT -{ - return unsafe_any_cast(const_cast(operand)); + return std::move(anys::any_cast(operand)); } } // namespace anys diff --git a/inst/include/boost/archive/basic_archive.hpp b/inst/include/boost/archive/basic_archive.hpp index 381a12750..d3c1e280c 100644 --- a/inst/include/boost/archive/basic_archive.hpp +++ b/inst/include/boost/archive/basic_archive.hpp @@ -60,7 +60,7 @@ class version_type { operator base_type () const { return t; } - // used for text intput + // used for text input operator base_type & (){ return t; } diff --git a/inst/include/boost/archive/basic_binary_iarchive.hpp b/inst/include/boost/archive/basic_binary_iarchive.hpp index 2ec90ce08..89a5ca1ac 100644 --- a/inst/include/boost/archive/basic_binary_iarchive.hpp +++ b/inst/include/boost/archive/basic_binary_iarchive.hpp @@ -10,7 +10,7 @@ // basic_binary_iarchive.hpp // // archives stored as native binary - this should be the fastest way -// to archive the state of a group of obects. It makes no attempt to +// to archive the state of a group of objects. It makes no attempt to // convert to any canonical form. // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE @@ -69,7 +69,7 @@ class BOOST_SYMBOL_VISIBLE basic_binary_iarchive : // intermediate level to support override of operators // fot templates in the absence of partial function // template ordering. If we get here pass to base class - // note extra nonsense to sneak it pass the borland compiers + // note extra nonsense to sneak it pass the borland compilers typedef detail::common_iarchive detail_common_iarchive; template void load_override(T & t){ diff --git a/inst/include/boost/archive/basic_binary_iprimitive.hpp b/inst/include/boost/archive/basic_binary_iprimitive.hpp index a29024072..f197ead00 100644 --- a/inst/include/boost/archive/basic_binary_iprimitive.hpp +++ b/inst/include/boost/archive/basic_binary_iprimitive.hpp @@ -14,7 +14,7 @@ // basic_binary_iprimitive.hpp // // archives stored as native binary - this should be the fastest way -// to archive the state of a group of obects. It makes no attempt to +// to archive the state of a group of objects. It makes no attempt to // convert to any canonical form. // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE @@ -89,7 +89,7 @@ class BOOST_SYMBOL_VISIBLE basic_binary_iprimitive { std::locale archive_locale; #endif - // main template for serilization of primitive types + // main template for serialization of primitive types template void load(T & t){ load_binary(& t, sizeof(T)); diff --git a/inst/include/boost/archive/basic_binary_oarchive.hpp b/inst/include/boost/archive/basic_binary_oarchive.hpp index 61bd8faac..92bab36d6 100644 --- a/inst/include/boost/archive/basic_binary_oarchive.hpp +++ b/inst/include/boost/archive/basic_binary_oarchive.hpp @@ -17,7 +17,7 @@ // See http://www.boost.org for updates, documentation, and revision history. // archives stored as native binary - this should be the fastest way -// to archive the state of a group of obects. It makes no attempt to +// to archive the state of a group of objects. It makes no attempt to // convert to any canonical form. // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE @@ -53,9 +53,9 @@ namespace detail { // class basic_binary_oarchive - write serialized objects to a binary output stream // note: this archive has no pretensions to portability. Archive format // may vary across machine architectures and compilers. About the only -// guarentee is that an archive created with this code will be readable -// by a program built with the same tools for the same machne. This class -// does have the virtue of buiding the smalles archive in the minimum amount +// guarantee is that an archive created with this code will be readable +// by a program built with the same tools for the same machine. This class +// does have the virtue of building the smallest archive in the minimum amount // of time. So under some circumstances it may be he right choice. template class BOOST_SYMBOL_VISIBLE basic_binary_oarchive : @@ -73,7 +73,7 @@ class BOOST_SYMBOL_VISIBLE basic_binary_oarchive : friend class detail::interface_oarchive; #endif #endif - // any datatype not specifed below will be handled by base class + // any datatype not specified below will be handled by base class typedef detail::common_oarchive detail_common_oarchive; template void save_override(const T & t){ diff --git a/inst/include/boost/archive/basic_binary_oprimitive.hpp b/inst/include/boost/archive/basic_binary_oprimitive.hpp index 6c5e8e5e9..bf44ac50d 100644 --- a/inst/include/boost/archive/basic_binary_oprimitive.hpp +++ b/inst/include/boost/archive/basic_binary_oprimitive.hpp @@ -17,7 +17,7 @@ // See http://www.boost.org for updates, documentation, and revision history. // archives stored as native binary - this should be the fastest way -// to archive the state of a group of obects. It makes no attempt to +// to archive the state of a group of objects. It makes no attempt to // convert to any canonical form. // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE @@ -56,7 +56,7 @@ namespace boost { namespace archive { ///////////////////////////////////////////////////////////////////////// -// class basic_binary_oprimitive - binary output of prmitives +// class basic_binary_oprimitive - binary output of primitives template class BOOST_SYMBOL_VISIBLE basic_binary_oprimitive { @@ -156,7 +156,7 @@ basic_binary_oprimitive::save_binary( // BOOST_ASSERT(count <= std::size_t(boost::integer_traits::const_max)); // note: if the following assertions fail // a likely cause is that the output stream is set to "text" - // mode where by cr characters recieve special treatment. + // mode where by cr characters receive special treatment. // be sure that the output stream is opened with ios::binary //if(os.fail()) // boost::serialization::throw_exception( diff --git a/inst/include/boost/archive/basic_text_oprimitive.hpp b/inst/include/boost/archive/basic_text_oprimitive.hpp index adc0e896f..3776958f0 100644 --- a/inst/include/boost/archive/basic_text_oprimitive.hpp +++ b/inst/include/boost/archive/basic_text_oprimitive.hpp @@ -61,7 +61,7 @@ namespace boost { namespace archive { ///////////////////////////////////////////////////////////////////////// -// class basic_text_oprimitive - output of prmitives to stream +// class basic_text_oprimitive - output of primitives to stream template class BOOST_SYMBOL_VISIBLE basic_text_oprimitive { @@ -159,17 +159,18 @@ class BOOST_SYMBOL_VISIBLE basic_text_oprimitive archive_exception(archive_exception::output_stream_error) ); } - // The formulae for the number of decimla digits required is given in + // The formulae for the number of decimal digits required is given in // http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf // which is derived from Kahan's paper: // www.eecs.berkeley.edu/~wkahan/ieee754status/ieee754.ps // const unsigned int digits = (std::numeric_limits::digits * 3010) / 10000; // note: I've commented out the above because I didn't get good results. e.g. // in one case I got a difference of 19 units. + const unsigned int digits = #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS - const unsigned int digits = std::numeric_limits::max_digits10; + std::numeric_limits::max_digits10; #else - const unsigned int digits = std::numeric_limits::digits10 + 2; + std::numeric_limits::digits10 + 2; #endif os << std::setprecision(digits) << std::scientific << t; } diff --git a/inst/include/boost/archive/binary_iarchive.hpp b/inst/include/boost/archive/binary_iarchive.hpp index 5052631a3..78e3e9a54 100644 --- a/inst/include/boost/archive/binary_iarchive.hpp +++ b/inst/include/boost/archive/binary_iarchive.hpp @@ -29,7 +29,7 @@ namespace boost { namespace archive { // do not derive from this class. If you want to extend this functionality -// via inhertance, derived from binary_iarchive_impl instead. This will +// via inheritance, derived from binary_iarchive_impl instead. This will // preserve correct static polymorphism. class BOOST_SYMBOL_VISIBLE binary_iarchive : public binary_iarchive_impl< diff --git a/inst/include/boost/archive/binary_oarchive.hpp b/inst/include/boost/archive/binary_oarchive.hpp index ba775d5c6..7197e7d5b 100644 --- a/inst/include/boost/archive/binary_oarchive.hpp +++ b/inst/include/boost/archive/binary_oarchive.hpp @@ -30,7 +30,7 @@ namespace boost { namespace archive { // do not derive from this class. If you want to extend this functionality -// via inhertance, derived from binary_oarchive_impl instead. This will +// via inheritance, derived from binary_oarchive_impl instead. This will // preserve correct static polymorphism. class BOOST_SYMBOL_VISIBLE binary_oarchive : public binary_oarchive_impl< diff --git a/inst/include/boost/archive/binary_woarchive.hpp b/inst/include/boost/archive/binary_woarchive.hpp index 6735ceba6..227fa9566 100644 --- a/inst/include/boost/archive/binary_woarchive.hpp +++ b/inst/include/boost/archive/binary_woarchive.hpp @@ -29,7 +29,7 @@ namespace boost { namespace archive { // do not derive from this class. If you want to extend this functionality -// via inhertance, derived from binary_oarchive_impl instead. This will +// via inheritance, derived from binary_oarchive_impl instead. This will // preserve correct static polymorphism. class binary_woarchive : public binary_oarchive_impl< diff --git a/inst/include/boost/archive/codecvt_null.hpp b/inst/include/boost/archive/codecvt_null.hpp index 3905d43ad..e78f126b3 100644 --- a/inst/include/boost/archive/codecvt_null.hpp +++ b/inst/include/boost/archive/codecvt_null.hpp @@ -52,7 +52,7 @@ class codecvt_null; template<> class codecvt_null : public std::codecvt { - bool do_always_noconv() const throw() BOOST_OVERRIDE { + bool do_always_noconv() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { return true; } public: @@ -88,15 +88,15 @@ class BOOST_SYMBOL_VISIBLE codecvt_null : wchar_t * & next2 ) const BOOST_OVERRIDE; - BOOST_SYMBOL_EXPORT int do_encoding( ) const throw( ) BOOST_OVERRIDE { + BOOST_SYMBOL_EXPORT int do_encoding( ) const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { return sizeof(wchar_t) / sizeof(char); } - BOOST_SYMBOL_EXPORT bool do_always_noconv() const throw() BOOST_OVERRIDE { + BOOST_SYMBOL_EXPORT bool do_always_noconv() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { return false; } - BOOST_SYMBOL_EXPORT int do_max_length( ) const throw( ) BOOST_OVERRIDE { + BOOST_SYMBOL_EXPORT int do_max_length( ) const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { return do_encoding(); } public: diff --git a/inst/include/boost/archive/detail/archive_serializer_map.hpp b/inst/include/boost/archive/detail/archive_serializer_map.hpp index 1e94e258a..6c12dcceb 100644 --- a/inst/include/boost/archive/detail/archive_serializer_map.hpp +++ b/inst/include/boost/archive/detail/archive_serializer_map.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// archive_serializer_map.hpp: extenstion of type_info required for +// archive_serializer_map.hpp: extension of type_info required for // serialization. // (C) Copyright 2009 Robert Ramey - http://www.rrsd.com . @@ -17,7 +17,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -// note: this is nothing more than the thinest of wrappers around +// note: this is nothing more than the thinnest of wrappers around // basic_serializer_map so we can have a one map / archive type. #include diff --git a/inst/include/boost/archive/detail/basic_iserializer.hpp b/inst/include/boost/archive/detail/basic_iserializer.hpp index 98c9c4745..e70fb65c8 100644 --- a/inst/include/boost/archive/detail/basic_iserializer.hpp +++ b/inst/include/boost/archive/detail/basic_iserializer.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_iserializer.hpp: extenstion of type_info required for serialization. +// basic_iserializer.hpp: extension of type_info required for serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software @@ -78,7 +78,7 @@ class BOOST_SYMBOL_VISIBLE basic_iserializer : virtual void destroy(/*const*/ void *address) const = 0 ; }; -} // namespae detail +} // namespace detail } // namespace archive } // namespace boost diff --git a/inst/include/boost/archive/detail/basic_oserializer.hpp b/inst/include/boost/archive/detail/basic_oserializer.hpp index b3f956776..b9d31969b 100644 --- a/inst/include/boost/archive/detail/basic_oserializer.hpp +++ b/inst/include/boost/archive/detail/basic_oserializer.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_oserializer.hpp: extenstion of type_info required for serialization. +// basic_oserializer.hpp: extension of type_info required for serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software diff --git a/inst/include/boost/archive/detail/basic_pointer_iserializer.hpp b/inst/include/boost/archive/detail/basic_pointer_iserializer.hpp index be805a42a..a499393f0 100644 --- a/inst/include/boost/archive/detail/basic_pointer_iserializer.hpp +++ b/inst/include/boost/archive/detail/basic_pointer_iserializer.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_pointer_oserializer.hpp: extenstion of type_info required for +// basic_pointer_oserializer.hpp: extension of type_info required for // serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . diff --git a/inst/include/boost/archive/detail/basic_pointer_oserializer.hpp b/inst/include/boost/archive/detail/basic_pointer_oserializer.hpp index 86376568a..58aec5772 100644 --- a/inst/include/boost/archive/detail/basic_pointer_oserializer.hpp +++ b/inst/include/boost/archive/detail/basic_pointer_oserializer.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_pointer_oserializer.hpp: extenstion of type_info required for +// basic_pointer_oserializer.hpp: extension of type_info required for // serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . diff --git a/inst/include/boost/archive/detail/basic_serializer.hpp b/inst/include/boost/archive/detail/basic_serializer.hpp index 9c2535bf3..30db65158 100644 --- a/inst/include/boost/archive/detail/basic_serializer.hpp +++ b/inst/include/boost/archive/detail/basic_serializer.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_serializer.hpp: extenstion of type_info required for serialization. +// basic_serializer.hpp: extension of type_info required for serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software diff --git a/inst/include/boost/archive/detail/basic_serializer_map.hpp b/inst/include/boost/archive/detail/basic_serializer_map.hpp index 78c6a52d3..07408cbc0 100644 --- a/inst/include/boost/archive/detail/basic_serializer_map.hpp +++ b/inst/include/boost/archive/detail/basic_serializer_map.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// basic_serializer_map.hpp: extenstion of type_info required for serialization. +// basic_serializer_map.hpp: extension of type_info required for serialization. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software diff --git a/inst/include/boost/archive/detail/check.hpp b/inst/include/boost/archive/detail/check.hpp index 5bf0a48bb..27d1db97c 100644 --- a/inst/include/boost/archive/detail/check.hpp +++ b/inst/include/boost/archive/detail/check.hpp @@ -94,7 +94,7 @@ inline void check_object_tracking(){ // may be an indicator of an error usage of the // serialization library and should be double checked. // See documentation on object tracking. Also, see the - // "rationale" section of the documenation + // "rationale" section of the documentation // for motivation for this checking. BOOST_STATIC_WARNING(typex::value); diff --git a/inst/include/boost/archive/detail/helper_collection.hpp b/inst/include/boost/archive/detail/helper_collection.hpp index edb4125e3..082ad33a6 100644 --- a/inst/include/boost/archive/detail/helper_collection.hpp +++ b/inst/include/boost/archive/detail/helper_collection.hpp @@ -55,10 +55,11 @@ class helper_collection collection m_collection; struct predicate { + BOOST_DEFAULTED_FUNCTION(predicate(const predicate& rhs), : m_ti(rhs.m_ti) {}) BOOST_DELETED_FUNCTION(predicate & operator=(const predicate & rhs)) public: const void * const m_ti; - bool operator()(helper_value_type const &rhs) const { + bool operator()(helper_value_type const &rhs){ return m_ti == rhs.first; } predicate(const void * ti) : diff --git a/inst/include/boost/archive/detail/interface_oarchive.hpp b/inst/include/boost/archive/detail/interface_oarchive.hpp index 44b47e619..88e857bc2 100644 --- a/inst/include/boost/archive/detail/interface_oarchive.hpp +++ b/inst/include/boost/archive/detail/interface_oarchive.hpp @@ -18,6 +18,7 @@ #include // NULL #include #include +#include #include #include @@ -44,7 +45,7 @@ class interface_oarchive // return a pointer to the most derived class Archive * This(){ - return static_cast(this); + return static_cast(this); } template diff --git a/inst/include/boost/archive/detail/iserializer.hpp b/inst/include/boost/archive/detail/iserializer.hpp index b1a9d438b..ce12f4790 100644 --- a/inst/include/boost/archive/detail/iserializer.hpp +++ b/inst/include/boost/archive/detail/iserializer.hpp @@ -169,12 +169,12 @@ BOOST_DLLEXPORT void iserializer::load_object_data( void *x, const unsigned int file_version ) const { - // note: we now comment this out. Before we permited archive + // note: we now comment this out. Before we permitted archive // version # to be very large. Now we don't. To permit // readers of these old archives, we have to suppress this // code. Perhaps in the future we might re-enable it but // permit its suppression with a runtime switch. - #if 0 + #if 1 // trap case where the program cannot handle the current version if(file_version > static_cast(version())) boost::serialization::throw_exception( @@ -184,7 +184,7 @@ BOOST_DLLEXPORT void iserializer::load_object_data( ) ); #endif - // make sure call is routed through the higest interface that might + // make sure call is routed through the highest interface that might // be specialized by the user. boost::serialization::serialize_adl( boost::serialization::smart_cast_reference(ar), @@ -308,7 +308,7 @@ class pointer_iserializer : const unsigned int file_version ) const BOOST_OVERRIDE BOOST_USED; public: - // this should alway be a singleton so make the constructor protected + // this should always be a singleton so make the constructor protected pointer_iserializer(); ~pointer_iserializer() BOOST_OVERRIDE; }; @@ -392,7 +392,7 @@ struct load_non_pointer_type { template static void invoke(Archive & ar, const T & t){ // short cut to user's serializer - // make sure call is routed through the higest interface that might + // make sure call is routed through the highest interface that might // be specialized by the user. boost::serialization::serialize_adl( ar, @@ -589,7 +589,7 @@ struct load_array_type { boost::archive::archive_exception::array_size_too_short ) ); - // explict template arguments to pass intel C++ compiler + // explicit template arguments to pass intel C++ compiler ar >> serialization::make_array< value_type, boost::serialization::collection_size_type diff --git a/inst/include/boost/archive/detail/oserializer.hpp b/inst/include/boost/archive/detail/oserializer.hpp index f6a77edfc..754fe97c2 100644 --- a/inst/include/boost/archive/detail/oserializer.hpp +++ b/inst/include/boost/archive/detail/oserializer.hpp @@ -509,7 +509,7 @@ struct save_array_type ); boost::serialization::collection_size_type count(c); ar << BOOST_SERIALIZATION_NVP(count); - // explict template arguments to pass intel C++ compiler + // explicit template arguments to pass intel C++ compiler ar << serialization::make_array< const value_type, boost::serialization::collection_size_type diff --git a/inst/include/boost/archive/impl/basic_xml_iarchive.ipp b/inst/include/boost/archive/impl/basic_xml_iarchive.ipp index f7490530e..289b31a36 100644 --- a/inst/include/boost/archive/impl/basic_xml_iarchive.ipp +++ b/inst/include/boost/archive/impl/basic_xml_iarchive.ipp @@ -10,6 +10,7 @@ #include #include // NULL +#include // strlen #include #include @@ -58,7 +59,10 @@ basic_xml_iarchive::load_end(const char *name){ if(0 == (this->get_flags() & no_xml_tag_checking)){ // double check that the tag matches what is expected - useful for debug - if(0 != name[this->This()->gimpl->rv.object_name.size()] + std::size_t parameter_name_length = std::strlen(name); + std::size_t object_name_length = this->This()->gimpl->rv.object_name.size(); + + if(parameter_name_length != object_name_length || ! std::equal( this->This()->gimpl->rv.object_name.begin(), this->This()->gimpl->rv.object_name.end(), diff --git a/inst/include/boost/archive/impl/basic_xml_oarchive.ipp b/inst/include/boost/archive/impl/basic_xml_oarchive.ipp index 3184413f3..f4947a047 100644 --- a/inst/include/boost/archive/impl/basic_xml_oarchive.ipp +++ b/inst/include/boost/archive/impl/basic_xml_oarchive.ipp @@ -33,7 +33,7 @@ struct XML_name { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0, // -. - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, // 0-9 + 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, // 0-9 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // A- 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, // -Z _ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // a- diff --git a/inst/include/boost/archive/impl/xml_oarchive_impl.ipp b/inst/include/boost/archive/impl/xml_oarchive_impl.ipp index 0f4ccbbf9..9f74c61d0 100644 --- a/inst/include/boost/archive/impl/xml_oarchive_impl.ipp +++ b/inst/include/boost/archive/impl/xml_oarchive_impl.ipp @@ -131,8 +131,9 @@ BOOST_ARCHIVE_DECL xml_oarchive_impl::~xml_oarchive_impl(){ if(boost::core::uncaught_exceptions() > 0) return; - if(0 == (this->get_flags() & no_header)) - this->windup(); + if(0 == (this->get_flags() & no_header)){ + this->put("\n"); + } } } // namespace archive diff --git a/inst/include/boost/archive/iterators/base64_from_binary.hpp b/inst/include/boost/archive/iterators/base64_from_binary.hpp index bd0b38fa5..99be6ce6e 100644 --- a/inst/include/boost/archive/iterators/base64_from_binary.hpp +++ b/inst/include/boost/archive/iterators/base64_from_binary.hpp @@ -84,7 +84,7 @@ class base64_from_binary : > super_t; public: - // make composible buy using templated constructor + // make composable by using templated constructor template base64_from_binary(T start) : super_t( diff --git a/inst/include/boost/archive/iterators/binary_from_base64.hpp b/inst/include/boost/archive/iterators/binary_from_base64.hpp index 5aeccb3aa..926eba0da 100644 --- a/inst/include/boost/archive/iterators/binary_from_base64.hpp +++ b/inst/include/boost/archive/iterators/binary_from_base64.hpp @@ -93,7 +93,7 @@ class binary_from_base64 : public Base > super_t; public: - // make composible buy using templated constructor + // make composable by using templated constructor template binary_from_base64(T start) : super_t( diff --git a/inst/include/boost/archive/iterators/dataflow_exception.hpp b/inst/include/boost/archive/iterators/dataflow_exception.hpp index a144a8bd6..0fa32b090 100644 --- a/inst/include/boost/archive/iterators/dataflow_exception.hpp +++ b/inst/include/boost/archive/iterators/dataflow_exception.hpp @@ -46,7 +46,7 @@ class dataflow_exception : public std::exception dataflow_exception(exception_code c = other_exception) : code(c) {} - const char *what( ) const throw( ) BOOST_OVERRIDE + const char *what( ) const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { const char *msg = "unknown exception code"; switch(code){ diff --git a/inst/include/boost/archive/iterators/escape.hpp b/inst/include/boost/archive/iterators/escape.hpp index 9af34ac9d..b40914410 100644 --- a/inst/include/boost/archive/iterators/escape.hpp +++ b/inst/include/boost/archive/iterators/escape.hpp @@ -82,7 +82,7 @@ class escape : } void increment(){ - if(++m_bnext < m_bend){ + if(m_bnext != NULL && ++m_bnext < m_bend){ m_current_value = *m_bnext; return; } diff --git a/inst/include/boost/archive/iterators/insert_linebreaks.hpp b/inst/include/boost/archive/iterators/insert_linebreaks.hpp index c75ea8415..a52d3f05b 100644 --- a/inst/include/boost/archive/iterators/insert_linebreaks.hpp +++ b/inst/include/boost/archive/iterators/insert_linebreaks.hpp @@ -79,7 +79,7 @@ class insert_linebreaks : } unsigned int m_count; public: - // make composible buy using templated constructor + // make composable by using templated constructor template insert_linebreaks(T start) : super_t(Base(static_cast< T >(start))), diff --git a/inst/include/boost/archive/iterators/mb_from_wchar.hpp b/inst/include/boost/archive/iterators/mb_from_wchar.hpp index dbd17b7c7..b6130f22b 100644 --- a/inst/include/boost/archive/iterators/mb_from_wchar.hpp +++ b/inst/include/boost/archive/iterators/mb_from_wchar.hpp @@ -18,6 +18,7 @@ #include #include // size_t +#include // memcpy #ifndef BOOST_NO_CWCHAR #include // mbstate_t #endif @@ -25,6 +26,7 @@ #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::mbstate_t; + using ::memcpy; } // namespace std #endif @@ -117,7 +119,7 @@ class mb_from_wchar bool m_full; public: - // make composible buy using templated constructor + // make composable by using templated constructor template mb_from_wchar(T start) : super_t(Base(static_cast< T >(start))), @@ -129,10 +131,13 @@ class mb_from_wchar // intel 7.1 doesn't like default copy constructor mb_from_wchar(const mb_from_wchar & rhs) : super_t(rhs.base_reference()), + m_mbs(rhs.m_mbs), m_bend(rhs.m_bend), m_bnext(rhs.m_bnext), m_full(rhs.m_full) - {} + { + std::memcpy(m_buffer, rhs.m_buffer, sizeof(m_buffer)); + } }; } // namespace iterators diff --git a/inst/include/boost/archive/iterators/remove_whitespace.hpp b/inst/include/boost/archive/iterators/remove_whitespace.hpp index eb756f379..bb549a8b0 100644 --- a/inst/include/boost/archive/iterators/remove_whitespace.hpp +++ b/inst/include/boost/archive/iterators/remove_whitespace.hpp @@ -149,7 +149,7 @@ class remove_whitespace : > super_t; public: // remove_whitespace(){} // why is this needed? - // make composible buy using templated constructor + // make composable by using templated constructor template remove_whitespace(T start) : super_t(Base(static_cast< T >(start))) diff --git a/inst/include/boost/archive/iterators/transform_width.hpp b/inst/include/boost/archive/iterators/transform_width.hpp index 162dccfa9..d1511912a 100644 --- a/inst/include/boost/archive/iterators/transform_width.hpp +++ b/inst/include/boost/archive/iterators/transform_width.hpp @@ -106,7 +106,7 @@ class transform_width : bool m_end_of_sequence; public: - // make composible buy using templated constructor + // make composable by using templated constructor template transform_width(T start) : super_t(Base(static_cast< T >(start))), diff --git a/inst/include/boost/archive/iterators/wchar_from_mb.hpp b/inst/include/boost/archive/iterators/wchar_from_mb.hpp index 6067245d3..65542b625 100644 --- a/inst/include/boost/archive/iterators/wchar_from_mb.hpp +++ b/inst/include/boost/archive/iterators/wchar_from_mb.hpp @@ -124,7 +124,7 @@ class wchar_from_mb sliding_buffer::type> m_output; public: - // make composible buy using templated constructor + // make composable by using templated constructor template wchar_from_mb(T start) : super_t(Base(static_cast< T >(start))), diff --git a/inst/include/boost/archive/iterators/xml_escape.hpp b/inst/include/boost/archive/iterators/xml_escape.hpp index c45733ea1..b018033cb 100644 --- a/inst/include/boost/archive/iterators/xml_escape.hpp +++ b/inst/include/boost/archive/iterators/xml_escape.hpp @@ -76,6 +76,8 @@ char xml_escape::fill( bend = bstart + 6; break; default: + bstart=""; + bend=bstart; return current_value; } return *bstart; diff --git a/inst/include/boost/archive/iterators/xml_unescape.hpp b/inst/include/boost/archive/iterators/xml_unescape.hpp index 7fc9fd5f6..1dc516858 100644 --- a/inst/include/boost/archive/iterators/xml_unescape.hpp +++ b/inst/include/boost/archive/iterators/xml_unescape.hpp @@ -79,7 +79,7 @@ void xml_unescape::drain_residue(const char * literal){ // note key constraint on this function is that can't "look ahead" any // more than necessary into base iterator. Doing so would alter the base -// iterator refenence which would make subsequent iterator comparisons +// iterator reference which would make subsequent iterator comparisons // incorrect and thereby break the composiblity of iterators. template typename xml_unescape::value_type diff --git a/inst/include/boost/array.hpp b/inst/include/boost/array.hpp index f047063d9..02bd76db7 100644 --- a/inst/include/boost/array.hpp +++ b/inst/include/boost/array.hpp @@ -33,18 +33,18 @@ #include -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(push) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe -# pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable:4510) // boost::array' : default constructor could not be generated +# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required #endif #include #include #include #include -#include +#include #include #include @@ -75,7 +75,7 @@ namespace boost { iterator begin() { return elems; } const_iterator begin() const { return elems; } const_iterator cbegin() const { return elems; } - + iterator end() { return elems+N; } const_iterator end() const { return elems+N; } const_iterator cend() const { return elems+N; } @@ -84,9 +84,9 @@ namespace boost { #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; #else @@ -112,39 +112,39 @@ namespace boost { } // operator[] - reference operator[](size_type i) - { - return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; + reference operator[](size_type i) + { + return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } - - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const - { - return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; + + /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const + { + return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } // at() with range check reference at(size_type i) { return rangecheck(i), elems[i]; } /*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; } - + // front() and back() - reference front() - { - return elems[0]; + reference front() + { + return elems[0]; } - - BOOST_CONSTEXPR const_reference front() const + + BOOST_CONSTEXPR const_reference front() const { return elems[0]; } - - reference back() - { - return elems[N-1]; + + reference back() + { + return elems[N-1]; } - - BOOST_CONSTEXPR const_reference back() const - { - return elems[N-1]; + + BOOST_CONSTEXPR const_reference back() const + { + return elems[N-1]; } // size is constant @@ -156,7 +156,7 @@ namespace boost { // swap (note: linear complexity) void swap (array& y) { for (size_type i = 0; i < N; ++i) - boost::swap(elems[i],y.elems[i]); + boost::core::invoke_swap(elems[i],y.elems[i]); } // direct access to data (read-only) @@ -213,9 +213,9 @@ namespace boost { #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; #else @@ -301,7 +301,7 @@ namespace boost { // assign one value to all elements void assign (const T& value) { fill ( value ); } void fill (const T& ) {} - + // check range (may be private because it is static) static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); @@ -353,16 +353,16 @@ namespace boost { #if defined(__SUNPRO_CC) // Trac ticket #4757; the Sun Solaris compiler can't handle // syntax like 'T(&get_c_array(boost::array& arg))[N]' -// -// We can't just use this for all compilers, because the -// borland compilers can't handle this form. +// +// We can't just use this for all compilers, because the +// borland compilers can't handle this form. namespace detail { template struct c_array { typedef T type[N]; }; } - + // Specific for boost::array: simply returns its elems data member. template typename detail::c_array::type& get_c_array(boost::array& arg) @@ -383,7 +383,7 @@ namespace boost { { return arg.elems; } - + // Const version. template const T(&get_c_array(const boost::array& arg))[N] @@ -391,7 +391,7 @@ namespace boost { return arg.elems; } #endif - + #if 0 // Overload for std::array, assuming that std::array will have // explicit conversion functions as discussed at the WG21 meeting @@ -401,7 +401,7 @@ namespace boost { { return static_cast(arg); } - + // Const version. template const T(&get_c_array(const std::array& arg))[N] @@ -423,7 +423,7 @@ namespace boost { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); return arr[Idx]; } - + template const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" ); @@ -440,7 +440,7 @@ namespace std { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" ); return arr[Idx]; } - + template const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" ); @@ -449,8 +449,8 @@ namespace std { } #endif -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(pop) -#endif +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif #endif /*BOOST_ARRAY_HPP*/ diff --git a/inst/include/boost/asio.hpp b/inst/include/boost/asio.hpp index ee6f0af4c..7b889de4a 100644 --- a/inst/include/boost/asio.hpp +++ b/inst/include/boost/asio.hpp @@ -2,7 +2,7 @@ // asio.hpp // ~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -23,8 +23,9 @@ #include #include #include -#include #include +#include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -80,30 +82,15 @@ #include #include #include -#include -#include -#include #include #include -#include #include #include #include #include -#include #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -112,9 +99,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -152,6 +137,7 @@ #include #include #include +#include #include #include #include @@ -178,6 +164,7 @@ #include #include #include +#include #include #include #include diff --git a/inst/include/boost/asio/any_completion_executor.hpp b/inst/include/boost/asio/any_completion_executor.hpp index 74933b96d..319fab23f 100644 --- a/inst/include/boost/asio/any_completion_executor.hpp +++ b/inst/include/boost/asio/any_completion_executor.hpp @@ -2,7 +2,7 @@ // any_completion_executor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -76,20 +76,18 @@ class any_completion_executor : #endif // !defined(GENERATING_DOCUMENTATION) /// Default constructor. - BOOST_ASIO_DECL any_completion_executor() BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL any_completion_executor() noexcept; /// Construct in an empty state. Equivalent effects to default constructor. - BOOST_ASIO_DECL any_completion_executor(nullptr_t) BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL any_completion_executor(nullptr_t) noexcept; /// Copy constructor. BOOST_ASIO_DECL any_completion_executor( - const any_completion_executor& e) BOOST_ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move constructor. BOOST_ASIO_DECL any_completion_executor( - any_completion_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_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) @@ -99,7 +97,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(BOOST_ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -123,7 +121,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) BOOST_ASIO_NOEXCEPT - : base_type(std::nothrow, BOOST_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. BOOST_ASIO_DECL any_completion_executor(std::nothrow_t, - const any_completion_executor& e) BOOST_ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. BOOST_ASIO_DECL any_completion_executor(std::nothrow_t, - any_completion_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + any_completion_executor&& e) noexcept; /// Construct a polymorphic wrapper for the specified executor. #if defined(GENERATING_DOCUMENTATION) @@ -156,7 +152,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(BOOST_ASIO_MOVE_CAST(Executor)(e)) + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -178,7 +174,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) BOOST_ASIO_NOEXCEPT - : base_type(std::nothrow, BOOST_ASIO_MOVE_CAST(Executor)(e)) + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Assignment operator. BOOST_ASIO_DECL any_completion_executor& operator=( - const any_completion_executor& e) BOOST_ASIO_NOEXCEPT; + const any_completion_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move assignment operator. BOOST_ASIO_DECL any_completion_executor& operator=( - any_completion_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + any_completion_executor&& e) noexcept; /// Assignment operator that sets the polymorphic wrapper to the empty state. BOOST_ASIO_DECL any_completion_executor& operator=(nullptr_t); @@ -210,7 +204,7 @@ class any_completion_executor : BOOST_ASIO_DECL ~any_completion_executor(); /// Swap targets with another polymorphic wrapper. - BOOST_ASIO_DECL void swap(any_completion_executor& other) BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL void swap(any_completion_executor& other) noexcept; /// Obtain a polymorphic wrapper with the specified property. /** @@ -223,9 +217,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); } @@ -241,9 +235,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/inst/include/boost/asio/any_completion_handler.hpp b/inst/include/boost/asio/any_completion_handler.hpp index b7510a824..17c727592 100644 --- a/inst/include/boost/asio/any_completion_handler.hpp +++ b/inst/include/boost/asio/any_completion_handler.hpp @@ -2,7 +2,7 @@ // any_completion_handler.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,20 +12,16 @@ #define BOOST_ASIO_ANY_COMPLETION_HANDLER_HPP #include - -#if (defined(BOOST_ASIO_HAS_STD_TUPLE) \ - && defined(BOOST_ASIO_HAS_MOVE) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include #include #include #include #include +#include #include #include #include +#include #include #include @@ -40,11 +36,11 @@ class any_completion_handler_impl_base public: template explicit any_completion_handler_impl_base(S&& slot) - : cancel_state_(BOOST_ASIO_MOVE_CAST(S)(slot), enable_total_cancellation()) + : cancel_state_(static_cast(slot), enable_total_cancellation()) { } - cancellation_slot get_cancellation_slot() const BOOST_ASIO_NOEXCEPT + cancellation_slot get_cancellation_slot() const noexcept { return cancel_state_.slot(); } @@ -60,8 +56,8 @@ class any_completion_handler_impl : public: template any_completion_handler_impl(S&& slot, H&& h) - : any_completion_handler_impl_base(BOOST_ASIO_MOVE_CAST(S)(slot)), - handler_(BOOST_ASIO_MOVE_CAST(H)(h)) + : any_completion_handler_impl_base(static_cast(slot)), + handler_(static_cast(h)) { } @@ -104,7 +100,7 @@ class any_completion_handler_impl : any_completion_handler_impl* ptr = new (uninit_ptr.get()) any_completion_handler_impl( - BOOST_ASIO_MOVE_CAST(S)(slot), BOOST_ASIO_MOVE_CAST(H)(h)); + static_cast(slot), static_cast(h)); uninit_ptr.release(); return ptr; @@ -120,12 +116,19 @@ class any_completion_handler_impl : } any_completion_executor executor( - const any_completion_executor& candidate) const BOOST_ASIO_NOEXCEPT + const any_completion_executor& candidate) const noexcept { return any_completion_executor(std::nothrow, (get_associated_executor)(handler_, candidate)); } + any_completion_executor immediate_executor( + const any_io_executor& candidate) const noexcept + { + return any_completion_executor(std::nothrow, + (get_associated_immediate_executor)(handler_, candidate)); + } + void* allocate(std::size_t size, std::size_t align) const { typename std::allocator_traits< @@ -181,11 +184,11 @@ class any_completion_handler_impl : boost::asio::recycling_allocator())}; std::unique_ptr ptr(this, d); - Handler handler(BOOST_ASIO_MOVE_CAST(Handler)(handler_)); + Handler handler(static_cast(handler_)); ptr.reset(); - BOOST_ASIO_MOVE_CAST(Handler)(handler)( - BOOST_ASIO_MOVE_CAST(Args)(args)...); + static_cast(handler)( + static_cast(args)...); } private: @@ -208,14 +211,14 @@ class any_completion_handler_call_fn void call(any_completion_handler_impl_base* impl, Args... args) const { - call_fn_(impl, BOOST_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( - BOOST_ASIO_MOVE_CAST(Args)(args)...); + static_cast(args)...); } private: @@ -306,6 +309,36 @@ class any_completion_handler_executor_fn type executor_fn_; }; +class any_completion_handler_immediate_executor_fn +{ +public: + using type = any_completion_executor(*)( + any_completion_handler_impl_base*, const any_io_executor&); + + constexpr any_completion_handler_immediate_executor_fn(type fn) + : immediate_executor_fn_(fn) + { + } + + any_completion_executor immediate_executor( + any_completion_handler_impl_base* impl, + const any_io_executor& candidate) const + { + return immediate_executor_fn_(impl, candidate); + } + + template + static any_completion_executor impl(any_completion_handler_impl_base* impl, + const any_io_executor& candidate) + { + return static_cast*>( + impl)->immediate_executor(candidate); + } + +private: + type immediate_executor_fn_; +}; + class any_completion_handler_allocate_fn { public: @@ -368,6 +401,7 @@ template class any_completion_handler_fn_table : private any_completion_handler_destroy_fn, private any_completion_handler_executor_fn, + private any_completion_handler_immediate_executor_fn, private any_completion_handler_allocate_fn, private any_completion_handler_deallocate_fn, private any_completion_handler_call_fns @@ -377,11 +411,13 @@ class any_completion_handler_fn_table constexpr any_completion_handler_fn_table( any_completion_handler_destroy_fn::type destroy_fn, any_completion_handler_executor_fn::type executor_fn, + any_completion_handler_immediate_executor_fn::type immediate_executor_fn, any_completion_handler_allocate_fn::type allocate_fn, any_completion_handler_deallocate_fn::type deallocate_fn, CallFns... call_fns) : any_completion_handler_destroy_fn(destroy_fn), any_completion_handler_executor_fn(executor_fn), + any_completion_handler_immediate_executor_fn(immediate_executor_fn), any_completion_handler_allocate_fn(allocate_fn), any_completion_handler_deallocate_fn(deallocate_fn), any_completion_handler_call_fns(call_fns...) @@ -390,6 +426,7 @@ class any_completion_handler_fn_table using any_completion_handler_destroy_fn::destroy; using any_completion_handler_executor_fn::executor; + using any_completion_handler_immediate_executor_fn::immediate_executor; using any_completion_handler_allocate_fn::allocate; using any_completion_handler_deallocate_fn::deallocate; using any_completion_handler_call_fns::call; @@ -402,6 +439,7 @@ struct any_completion_handler_fn_table_instance value = any_completion_handler_fn_table( &any_completion_handler_destroy_fn::impl, &any_completion_handler_executor_fn::impl, + &any_completion_handler_immediate_executor_fn::impl, &any_completion_handler_allocate_fn::impl, &any_completion_handler_deallocate_fn::impl, &any_completion_handler_call_fn::template impl...); @@ -416,6 +454,8 @@ any_completion_handler_fn_table_instance::value; template class any_completion_handler; +/// An allocator type that forwards memory allocation operations through an +/// instance of @c any_completion_handler. template class any_completion_handler_allocator { @@ -430,55 +470,72 @@ class any_completion_handler_allocator detail::any_completion_handler_impl_base* impl_; constexpr any_completion_handler_allocator(int, - const any_completion_handler& h) BOOST_ASIO_NOEXCEPT + const any_completion_handler& h) noexcept : fn_table_(h.fn_table_), impl_(h.impl_) { } public: + /// The type of objects that may be allocated by the allocator. typedef T value_type; + /// Rebinds an allocator to another value type. template struct rebind { + /// Specifies the type of the rebound allocator. typedef any_completion_handler_allocator other; }; + /// Construct from another @c any_completion_handler_allocator. template constexpr any_completion_handler_allocator( const any_completion_handler_allocator& a) - BOOST_ASIO_NOEXCEPT + noexcept : fn_table_(a.fn_table_), impl_(a.impl_) { } + /// Equality operator. constexpr bool operator==( - const any_completion_handler_allocator& other) const BOOST_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 BOOST_ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ != other.fn_table_ || impl_ != other.impl_; } + /// Allocate space for @c n objects of the allocator's value type. T* allocate(std::size_t n) const { - return static_cast( - fn_table_->allocate( - impl_, sizeof(T) * n, alignof(T))); + if (fn_table_) + { + return static_cast( + fn_table_->allocate( + impl_, sizeof(T) * n, alignof(T))); + } + std::bad_alloc ex; + boost::asio::detail::throw_exception(ex); + return nullptr; } + /// Deallocate space for @c n objects of the allocator's value type. void deallocate(T* p, std::size_t n) const { fn_table_->deallocate(impl_, p, sizeof(T) * n, alignof(T)); } }; +/// A protoco-allocator type that may be rebound to obtain an allocator that +/// forwards memory allocation operations through an instance of +/// @c any_completion_handler. template class any_completion_handler_allocator { @@ -493,46 +550,70 @@ class any_completion_handler_allocator detail::any_completion_handler_impl_base* impl_; constexpr any_completion_handler_allocator(int, - const any_completion_handler& h) BOOST_ASIO_NOEXCEPT + const any_completion_handler& h) noexcept : fn_table_(h.fn_table_), impl_(h.impl_) { } public: + /// @c void as no objects can be allocated through a proto-allocator. typedef void value_type; + /// Rebinds an allocator to another value type. template struct rebind { + /// Specifies the type of the rebound allocator. typedef any_completion_handler_allocator other; }; + /// Construct from another @c any_completion_handler_allocator. template constexpr any_completion_handler_allocator( const any_completion_handler_allocator& a) - BOOST_ASIO_NOEXCEPT + noexcept : fn_table_(a.fn_table_), impl_(a.impl_) { } + /// Equality operator. constexpr bool operator==( - const any_completion_handler_allocator& other) const BOOST_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 BOOST_ASIO_NOEXCEPT + const any_completion_handler_allocator& other) const noexcept { return fn_table_ != other.fn_table_ || impl_ != other.impl_; } }; +/// Polymorphic wrapper for completion handlers. +/** + * The @c any_completion_handler class template is a polymorphic wrapper for + * completion handlers that propagates the associated executor, associated + * allocator, and associated cancellation slot through a type-erasing interface. + * + * When using @c any_completion_handler, specify one or more completion + * signatures as template parameters. These will dictate the arguments that may + * be passed to the handler through the polymorphic interface. + * + * Typical uses for @c any_completion_handler include: + * + * @li Separate compilation of asynchronous operation implementations. + * + * @li Enabling interoperability between asynchronous operations and virtual + * functions. + */ template class any_completion_handler { +#if !defined(GENERATING_DOCUMENTATION) private: template friend class any_completion_handler_allocator; @@ -540,36 +621,55 @@ class any_completion_handler template friend struct associated_executor; + template + friend struct associated_immediate_executor; + const detail::any_completion_handler_fn_table* fn_table_; detail::any_completion_handler_impl_base* impl_; +#endif // !defined(GENERATING_DOCUMENTATION) public: + /// The associated allocator type. using allocator_type = any_completion_handler_allocator; + + /// The associated cancellation slot type. using cancellation_slot_type = cancellation_slot; + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. constexpr any_completion_handler() : fn_table_(nullptr), impl_(nullptr) { } + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. constexpr any_completion_handler(nullptr_t) : fn_table_(nullptr), impl_(nullptr) { } - template ::type> - any_completion_handler(H&& h) + /// Construct an @c any_completion_handler to contain the specified target. + template > + any_completion_handler(H&& h, + constraint_t< + !is_same, any_completion_handler>::value + > = 0) : fn_table_( &detail::any_completion_handler_fn_table_instance< Handler, Signatures...>::value), impl_(detail::any_completion_handler_impl::create( - (get_associated_cancellation_slot)(h), BOOST_ASIO_MOVE_CAST(H)(h))) + (get_associated_cancellation_slot)(h), static_cast(h))) { } - any_completion_handler(any_completion_handler&& other) BOOST_ASIO_NOEXCEPT + /// Move-construct an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ + any_completion_handler(any_completion_handler&& other) noexcept : fn_table_(other.fn_table_), impl_(other.impl_) { @@ -577,84 +677,109 @@ class any_completion_handler other.impl_ = nullptr; } + /// Move-assign an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ any_completion_handler& operator=( - any_completion_handler&& other) BOOST_ASIO_NOEXCEPT + any_completion_handler&& other) noexcept { - any_completion_handler(other).swap(*this); + any_completion_handler( + static_cast(other)).swap(*this); return *this; } - any_completion_handler& operator=(nullptr_t) BOOST_ASIO_NOEXCEPT + /// Assignment operator that sets the polymorphic wrapper to the empty state. + any_completion_handler& operator=(nullptr_t) noexcept { any_completion_handler().swap(*this); return *this; } + /// Destructor. ~any_completion_handler() { if (impl_) fn_table_->destroy(impl_); } - constexpr explicit operator bool() const BOOST_ASIO_NOEXCEPT + /// Test if the polymorphic wrapper is empty. + constexpr explicit operator bool() const noexcept { return impl_ != nullptr; } - constexpr bool operator!() const BOOST_ASIO_NOEXCEPT + /// Test if the polymorphic wrapper is non-empty. + constexpr bool operator!() const noexcept { return impl_ == nullptr; } - void swap(any_completion_handler& other) BOOST_ASIO_NOEXCEPT + /// Swap the content of an @c any_completion_handler with another. + void swap(any_completion_handler& other) noexcept { std::swap(fn_table_, other.fn_table_); std::swap(impl_, other.impl_); } - allocator_type get_allocator() const BOOST_ASIO_NOEXCEPT + /// Get the associated allocator. + allocator_type get_allocator() const noexcept { return allocator_type(0, *this); } - cancellation_slot_type get_cancellation_slot() const BOOST_ASIO_NOEXCEPT + /// Get the associated cancellation slot. + cancellation_slot_type get_cancellation_slot() const noexcept { - return impl_->get_cancellation_slot(); + return impl_ ? impl_->get_cancellation_slot() : cancellation_slot_type(); } + /// Function call operator. + /** + * Invokes target completion handler with the supplied arguments. + * + * This function may only be called once, as the target handler is moved from. + * The polymorphic wrapper is left in an empty state. + * + * Throws @c std::bad_function_call if the polymorphic wrapper is empty. + */ template auto operator()(Args&&... args) - -> decltype(fn_table_->call(impl_, BOOST_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, BOOST_ASIO_MOVE_CAST(Args)(args)...); + return fn_table_->call(impl, static_cast(args)...); } std::bad_function_call ex; boost::asio::detail::throw_exception(ex); } + /// Equality operator. friend constexpr bool operator==( - const any_completion_handler& a, nullptr_t) BOOST_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) BOOST_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) BOOST_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) BOOST_ASIO_NOEXCEPT + nullptr_t, const any_completion_handler& b) noexcept { return nullptr != b.impl_; } @@ -666,10 +791,28 @@ struct associated_executor, Candidate> using type = any_completion_executor; static type get(const any_completion_handler& handler, - const Candidate& candidate = Candidate()) BOOST_ASIO_NOEXCEPT + const Candidate& candidate = Candidate()) noexcept { - return handler.fn_table_->executor(handler.impl_, - any_completion_executor(std::nothrow, candidate)); + any_completion_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->executor(handler.impl_, any_candidate) + : any_candidate; + } +}; + +template +struct associated_immediate_executor< + any_completion_handler, Candidate> +{ + using type = any_completion_executor; + + static type get(const any_completion_handler& handler, + const Candidate& candidate = Candidate()) noexcept + { + any_io_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->immediate_executor(handler.impl_, any_candidate) + : any_candidate; } }; @@ -678,9 +821,4 @@ struct associated_executor, Candidate> #include -#endif // (defined(BOOST_ASIO_HAS_STD_TUPLE) - // && defined(BOOST_ASIO_HAS_MOVE) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // BOOST_ASIO_ANY_COMPLETION_HANDLER_HPP diff --git a/inst/include/boost/asio/any_io_executor.hpp b/inst/include/boost/asio/any_io_executor.hpp index 523ae94d2..4d6a058d9 100644 --- a/inst/include/boost/asio/any_io_executor.hpp +++ b/inst/include/boost/asio/any_io_executor.hpp @@ -2,7 +2,7 @@ // any_io_executor.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -88,18 +88,16 @@ class any_io_executor : #endif // !defined(GENERATING_DOCUMENTATION) /// Default constructor. - BOOST_ASIO_DECL any_io_executor() BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL any_io_executor() noexcept; /// Construct in an empty state. Equivalent effects to default constructor. - BOOST_ASIO_DECL any_io_executor(nullptr_t) BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL any_io_executor(nullptr_t) noexcept; /// Copy constructor. - BOOST_ASIO_DECL any_io_executor(const any_io_executor& e) BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL any_io_executor(const any_io_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move constructor. - BOOST_ASIO_DECL any_io_executor(any_io_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + BOOST_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) @@ -108,8 +106,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, @@ -117,9 +115,9 @@ class any_io_executor : 0, supportable_properties_type>::template is_valid_target, false_type - >::type::value - >::type = 0) - : base_type(BOOST_ASIO_MOVE_CAST(OtherAnyExecutor)(e)) + >::value + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -132,8 +130,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, @@ -141,22 +139,19 @@ class any_io_executor : 0, supportable_properties_type>::template is_valid_target, false_type - >::type::value - >::type = 0) BOOST_ASIO_NOEXCEPT - : base_type(std::nothrow, BOOST_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. BOOST_ASIO_DECL any_io_executor(std::nothrow_t, - const any_io_executor& e) BOOST_ASIO_NOEXCEPT; + const any_io_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. - BOOST_ASIO_DECL any_io_executor(std::nothrow_t, - any_io_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + BOOST_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) @@ -165,17 +160,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(BOOST_ASIO_MOVE_CAST(Executor)(e)) + >::value + > = 0) + : base_type(static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) @@ -187,30 +182,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) BOOST_ASIO_NOEXCEPT - : base_type(std::nothrow, BOOST_ASIO_MOVE_CAST(Executor)(e)) + >::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Assignment operator. BOOST_ASIO_DECL any_io_executor& operator=( - const any_io_executor& e) BOOST_ASIO_NOEXCEPT; + const any_io_executor& e) noexcept; -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move assignment operator. - BOOST_ASIO_DECL any_io_executor& operator=( - any_io_executor&& e) BOOST_ASIO_NOEXCEPT; -#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + BOOST_ASIO_DECL any_io_executor& operator=(any_io_executor&& e) noexcept; /// Assignment operator that sets the polymorphic wrapper to the empty state. BOOST_ASIO_DECL any_io_executor& operator=(nullptr_t); @@ -219,7 +211,7 @@ class any_io_executor : BOOST_ASIO_DECL ~any_io_executor(); /// Swap targets with another polymorphic wrapper. - BOOST_ASIO_DECL void swap(any_io_executor& other) BOOST_ASIO_NOEXCEPT; + BOOST_ASIO_DECL void swap(any_io_executor& other) noexcept; /// Obtain a polymorphic wrapper with the specified property. /** @@ -232,9 +224,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); } @@ -250,9 +242,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/inst/include/boost/asio/append.hpp b/inst/include/boost/asio/append.hpp index 0963236f6..fc3d86249 100644 --- a/inst/include/boost/asio/append.hpp +++ b/inst/include/boost/asio/append.hpp @@ -2,7 +2,7 @@ // append.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,11 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include - -#if (defined(BOOST_ASIO_HAS_STD_TUPLE) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include #include @@ -38,11 +33,9 @@ class append_t public: /// Constructor. template - BOOST_ASIO_CONSTEXPR explicit append_t( - BOOST_ASIO_MOVE_ARG(T) completion_token, - BOOST_ASIO_MOVE_ARG(V)... values) - : token_(BOOST_ASIO_MOVE_CAST(T)(completion_token)), - values_(BOOST_ASIO_MOVE_CAST(V)(values)...) + constexpr explicit append_t(T&& completion_token, V&&... values) + : token_(static_cast(completion_token)), + values_(static_cast(values)...) { } @@ -55,15 +48,13 @@ class append_t /// arguments should be passed additional values after the results of the /// operation. template -BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONSTEXPR append_t< - typename decay::type, typename decay::type...> -append(BOOST_ASIO_MOVE_ARG(CompletionToken) completion_token, - BOOST_ASIO_MOVE_ARG(Values)... values) +BOOST_ASIO_NODISCARD inline constexpr +append_t, decay_t...> +append(CompletionToken&& completion_token, Values&&... values) { - return append_t< - typename decay::type, typename decay::type...>( - BOOST_ASIO_MOVE_CAST(CompletionToken)(completion_token), - BOOST_ASIO_MOVE_CAST(Values)(values)...); + return append_t, decay_t...>( + static_cast(completion_token), + static_cast(values)...); } } // namespace asio @@ -73,8 +64,4 @@ append(BOOST_ASIO_MOVE_ARG(CompletionToken) completion_token, #include -#endif // (defined(BOOST_ASIO_HAS_STD_TUPLE) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // BOOST_ASIO_APPEND_HPP diff --git a/inst/include/boost/asio/as_tuple.hpp b/inst/include/boost/asio/as_tuple.hpp index 613fe1add..0f89b4600 100644 --- a/inst/include/boost/asio/as_tuple.hpp +++ b/inst/include/boost/asio/as_tuple.hpp @@ -2,7 +2,7 @@ // as_tuple.hpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,11 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include - -#if (defined(BOOST_ASIO_HAS_STD_TUPLE) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) \ - || defined(GENERATING_DOCUMENTATION) - #include #include @@ -51,18 +46,18 @@ class as_tuple_t * token is itself defaulted as an argument to allow it to capture a source * location. */ - BOOST_ASIO_CONSTEXPR as_tuple_t( + constexpr as_tuple_t( default_constructor_tag = default_constructor_tag(), CompletionToken token = CompletionToken()) - : token_(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)) + : token_(static_cast(token)) { } /// Constructor. template - BOOST_ASIO_CONSTEXPR explicit as_tuple_t( - BOOST_ASIO_MOVE_ARG(T) completion_token) - : token_(BOOST_ASIO_MOVE_CAST(T)(completion_token)) + constexpr explicit as_tuple_t( + T&& completion_token) + : token_(static_cast(completion_token)) { } @@ -77,13 +72,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) BOOST_ASIO_NOEXCEPT + >::value + > = 0) noexcept : InnerExecutor(ex) { } @@ -91,25 +86,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(BOOST_ASIO_HAS_ALIAS_TEMPLATES) \ - || defined(GENERATING_DOCUMENTATION) template using as_default_on_t = typename T::template rebind_executor< - executor_with_default >::other; -#endif // defined(BOOST_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(BOOST_ASIO_MOVE_ARG(T) object) + as_default_on(T&& object) { - return typename decay::type::template rebind_executor< - executor_with_default::type::executor_type> - >::other(BOOST_ASIO_MOVE_CAST(T)(object)); + return typename decay_t::template rebind_executor< + executor_with_default::executor_type> + >::other(static_cast(object)); } //private: @@ -120,11 +111,11 @@ class as_tuple_t /// arguments should be combined into a single tuple argument. template BOOST_ASIO_NODISCARD inline -BOOST_ASIO_CONSTEXPR as_tuple_t::type> -as_tuple(BOOST_ASIO_MOVE_ARG(CompletionToken) completion_token) +constexpr as_tuple_t> +as_tuple(CompletionToken&& completion_token) { - return as_tuple_t::type>( - BOOST_ASIO_MOVE_CAST(CompletionToken)(completion_token)); + return as_tuple_t>( + static_cast(completion_token)); } } // namespace asio @@ -134,8 +125,4 @@ as_tuple(BOOST_ASIO_MOVE_ARG(CompletionToken) completion_token) #include -#endif // (defined(BOOST_ASIO_HAS_STD_TUPLE) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) - // || defined(GENERATING_DOCUMENTATION) - #endif // BOOST_ASIO_AS_TUPLE_HPP diff --git a/inst/include/boost/asio/associated_allocator.hpp b/inst/include/boost/asio/associated_allocator.hpp index ed085703e..38825fa31 100644 --- a/inst/include/boost/asio/associated_allocator.hpp +++ b/inst/include/boost/asio/associated_allocator.hpp @@ -2,7 +2,7 @@ // associated_allocator.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -37,9 +37,7 @@ struct has_allocator_type : false_type }; template -struct has_allocator_type::type> - : true_type +struct has_allocator_type> : true_type { }; @@ -50,33 +48,30 @@ struct associated_allocator_impl typedef A type; - static type get(const T&) BOOST_ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const A& a) BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_allocator())) + static auto get(const T& t) noexcept + -> decltype(t.get_allocator()) { return t.get_allocator(); } - static BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const A&) BOOST_ASIO_NOEXCEPT - BOOST_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(); } @@ -84,12 +79,12 @@ struct associated_allocator_impl struct associated_allocator_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -116,7 +111,7 @@ struct associated_allocator_impl > +template > struct associated_allocator #if !defined(GENERATING_DOCUMENTATION) : detail::associated_allocator_impl @@ -129,11 +124,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) BOOST_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) BOOST_ASIO_NOEXCEPT; + static decltype(auto) get(const T& t, const Allocator& a) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -143,7 +138,7 @@ struct associated_allocator */ template BOOST_ASIO_NODISCARD inline typename associated_allocator::type -get_associated_allocator(const T& t) BOOST_ASIO_NOEXCEPT +get_associated_allocator(const T& t) noexcept { return associated_allocator::get(t); } @@ -153,23 +148,17 @@ get_associated_allocator(const T& t) BOOST_ASIO_NOEXCEPT * @returns associated_allocator::get(t, a) */ template -BOOST_ASIO_NODISCARD inline BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_allocator::type) -get_associated_allocator(const T& t, const Allocator& a) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_allocator::get(t, a))) +BOOST_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(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - -template > +template > using associated_allocator_t = typename associated_allocator::type; -#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -179,22 +168,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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_allocator for @c std::reference_wrapper. template struct associated_allocator, Allocator> @@ -208,25 +194,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) BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - reference_wrapper t, const Allocator& a) BOOST_ASIO_NOEXCEPT - BOOST_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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio } // namespace boost diff --git a/inst/include/boost/asio/associated_cancellation_slot.hpp b/inst/include/boost/asio/associated_cancellation_slot.hpp index 3ee637ff2..e44bff9f4 100644 --- a/inst/include/boost/asio/associated_cancellation_slot.hpp +++ b/inst/include/boost/asio/associated_cancellation_slot.hpp @@ -2,7 +2,7 @@ // associated_cancellation_slot.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -37,9 +37,8 @@ struct has_cancellation_slot_type : false_type }; template -struct has_cancellation_slot_type::type> - : true_type +struct has_cancellation_slot_type> + : true_type { }; @@ -50,12 +49,12 @@ struct associated_cancellation_slot_impl typedef S type; - static type get(const T&) BOOST_ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const S& s) BOOST_ASIO_NOEXCEPT + static const type& get(const T&, const S& s) noexcept { return s; } @@ -63,20 +62,18 @@ struct associated_cancellation_slot_impl template struct associated_cancellation_slot_impl::type> + void_t> { typedef typename T::cancellation_slot_type type; - static BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) BOOST_ASIO_NOEXCEPT - BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const S&) BOOST_ASIO_NOEXCEPT - BOOST_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(); } @@ -84,12 +81,12 @@ struct associated_cancellation_slot_impl struct associated_cancellation_slot_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -130,12 +127,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) BOOST_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) BOOST_ASIO_NOEXCEPT; + const CancellationSlot& s) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -145,7 +142,7 @@ struct associated_cancellation_slot */ template BOOST_ASIO_NODISCARD inline typename associated_cancellation_slot::type -get_associated_cancellation_slot(const T& t) BOOST_ASIO_NOEXCEPT +get_associated_cancellation_slot(const T& t) noexcept { return associated_cancellation_slot::get(t); } @@ -156,24 +153,17 @@ get_associated_cancellation_slot(const T& t) BOOST_ASIO_NOEXCEPT * CancellationSlot>::get(t, st) */ template -BOOST_ASIO_NODISCARD inline BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_cancellation_slot::type) -get_associated_cancellation_slot(const T& t, - const CancellationSlot& st) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_cancellation_slot::get(t, st))) +BOOST_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(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - template using associated_cancellation_slot_t = typename associated_cancellation_slot::type; -#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -183,22 +173,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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_cancellation_slot for @c /// std::reference_wrapper. template @@ -213,25 +200,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) BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get(reference_wrapper t, - const CancellationSlot& s = CancellationSlot()) BOOST_ASIO_NOEXCEPT - BOOST_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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio } // namespace boost diff --git a/inst/include/boost/asio/associated_executor.hpp b/inst/include/boost/asio/associated_executor.hpp index a110182cb..a8d4776a0 100644 --- a/inst/include/boost/asio/associated_executor.hpp +++ b/inst/include/boost/asio/associated_executor.hpp @@ -2,7 +2,7 @@ // associated_executor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -39,8 +39,7 @@ struct has_executor_type : false_type }; template -struct has_executor_type::type> +struct has_executor_type> : true_type { }; @@ -52,33 +51,30 @@ struct associated_executor_impl typedef E type; - static type get(const T&) BOOST_ASIO_NOEXCEPT + static type get(const T&) noexcept { return type(); } - static const type& get(const T&, const E& e) BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((t.get_executor())) + static auto get(const T& t) noexcept + -> decltype(t.get_executor()) { return t.get_executor(); } - static BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - const T& t, const E&) BOOST_ASIO_NOEXCEPT - BOOST_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(); } @@ -86,12 +82,12 @@ struct associated_executor_impl struct associated_executor_impl::value - >::type, - typename void_type< + >, + void_t< typename associator::type - >::type> : associator + >> : associator { }; @@ -131,11 +127,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) BOOST_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) BOOST_ASIO_NOEXCEPT; + static decltype(auto) get(const T& t, const Executor& ex) noexcept; #endif // defined(GENERATING_DOCUMENTATION) }; @@ -145,7 +141,7 @@ struct associated_executor */ template BOOST_ASIO_NODISCARD inline typename associated_executor::type -get_associated_executor(const T& t) BOOST_ASIO_NOEXCEPT +get_associated_executor(const T& t) noexcept { return associated_executor::get(t); } @@ -155,14 +151,12 @@ get_associated_executor(const T& t) BOOST_ASIO_NOEXCEPT * @returns associated_executor::get(t, ex) */ template -BOOST_ASIO_NODISCARD inline BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_executor::type) -get_associated_executor(const T& t, const Executor& ex, - typename constraint< +BOOST_ASIO_NODISCARD inline auto get_associated_executor( + const T& t, const Executor& ex, + constraint_t< is_executor::value || execution::is_executor::value - >::type = 0) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_executor::get(t, ex))) + > = 0) noexcept + -> decltype(associated_executor::get(t, ex)) { return associated_executor::get(t, ex); } @@ -173,27 +167,19 @@ get_associated_executor(const T& t, const Executor& ex, * ExecutionContext::executor_type>::get(t, ctx.get_executor()) */ template -BOOST_ASIO_NODISCARD inline BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2( - typename associated_executor::type) +BOOST_ASIO_NODISCARD inline typename associated_executor::type get_associated_executor(const T& t, ExecutionContext& ctx, - typename constraint::value>::type = 0) BOOST_ASIO_NOEXCEPT - BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX(( - associated_executor::get(t, ctx.get_executor()))) + constraint_t::value> = 0) noexcept { return associated_executor::get(t, ctx.get_executor()); } -#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - template using associated_executor_t = typename associated_executor::type; -#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) - namespace detail { template @@ -203,22 +189,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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - /// Specialisation of associated_executor for @c std::reference_wrapper. template struct associated_executor, Executor> @@ -232,25 +215,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) BOOST_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 BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX(type) get( - reference_wrapper t, const Executor& ex) BOOST_ASIO_NOEXCEPT - BOOST_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(BOOST_ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - } // namespace asio } // namespace boost diff --git a/inst/include/boost/asio/associated_immediate_executor.hpp b/inst/include/boost/asio/associated_immediate_executor.hpp new file mode 100644 index 000000000..ff0b8b882 --- /dev/null +++ b/inst/include/boost/asio/associated_immediate_executor.hpp @@ -0,0 +1,282 @@ +// +// associated_immediate_executor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP +#define BOOST_ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { + +template +struct associated_immediate_executor; + +namespace detail { + +template +struct has_immediate_executor_type : false_type +{ +}; + +template +struct has_immediate_executor_type> + : true_type +{ +}; + +template +struct default_immediate_executor +{ + typedef require_result_t type; + + static type get(const E& e) noexcept + { + return boost::asio::require(e, execution::blocking.never); + } +}; + +template +struct default_immediate_executor::value + >, + enable_if_t< + is_executor::value + >> +{ + class type : public E + { + public: + template + explicit type(const Executor1& e, + constraint_t< + conditional_t< + !is_same::value, + is_convertible, + false_type + >::value + > = 0) noexcept + : E(e) + { + } + + type(const type& other) noexcept + : E(static_cast(other)) + { + } + + type(type&& other) noexcept + : E(static_cast(other)) + { + } + + template + void dispatch(Function&& f, const Allocator& a) const + { + this->post(static_cast(f), a); + } + + friend bool operator==(const type& a, const type& b) noexcept + { + return static_cast(a) == static_cast(b); + } + + friend bool operator!=(const type& a, const type& b) noexcept + { + return static_cast(a) != static_cast(b); + } + }; + + static type get(const E& e) noexcept + { + return type(e); + } +}; + +template +struct associated_immediate_executor_impl +{ + typedef void asio_associated_immediate_executor_is_unspecialised; + + typedef typename default_immediate_executor::type type; + + static auto get(const T&, const E& e) noexcept + -> decltype(default_immediate_executor::get(e)) + { + return default_immediate_executor::get(e); + } +}; + +template +struct associated_immediate_executor_impl> +{ + typedef typename T::immediate_executor_type type; + + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_immediate_executor()) + { + return t.get_immediate_executor(); + } +}; + +template +struct associated_immediate_executor_impl::value + >, + void_t< + typename associator::type + >> : associator +{ +}; + +} // namespace detail + +/// Traits type used to obtain the immediate executor associated with an object. +/** + * A program may specialise this traits type if the @c T template parameter in + * the specialisation is a user-defined type. The template parameter @c + * Executor shall be a type meeting the Executor requirements. + * + * Specialisations shall meet the following requirements, where @c t is a const + * reference to an object of type @c T, and @c e is an object of type @c + * Executor. + * + * @li Provide a nested typedef @c type that identifies a type meeting the + * Executor requirements. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t) and with return type @c type or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,e) and with return type @c type or a (possibly const) reference to @c + * type. + */ +template +struct associated_immediate_executor +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_impl +#endif // !defined(GENERATING_DOCUMENTATION) +{ +#if defined(GENERATING_DOCUMENTATION) + /// If @c T has a nested type @c immediate_executor_type, + // T::immediate_executor_type. Otherwise @c Executor. + typedef see_below type; + + /// If @c T has a nested type @c immediate_executor_type, returns + /// t.get_immediate_executor(). Otherwise returns + /// boost::asio::require(ex, boost::asio::execution::blocking.never). + static decltype(auto) get(const T& t, const Executor& ex) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ex) + */ +template +BOOST_ASIO_NODISCARD inline auto get_associated_immediate_executor( + const T& t, const Executor& ex, + constraint_t< + is_executor::value || execution::is_executor::value + > = 0) noexcept + -> decltype(associated_immediate_executor::get(t, ex)) +{ + return associated_immediate_executor::get(t, ex); +} + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ctx.get_executor()) + */ +template +BOOST_ASIO_NODISCARD inline typename associated_immediate_executor::type +get_associated_immediate_executor(const T& t, ExecutionContext& ctx, + constraint_t< + is_convertible::value + > = 0) noexcept +{ + return associated_immediate_executor::get(t, ctx.get_executor()); +} + +template +using associated_immediate_executor_t = + typename associated_immediate_executor::type; + +namespace detail { + +template +struct associated_immediate_executor_forwarding_base +{ +}; + +template +struct associated_immediate_executor_forwarding_base::asio_associated_immediate_executor_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_immediate_executor_is_unspecialised; +}; + +} // namespace detail + +/// Specialisation of associated_immediate_executor for +/// @c std::reference_wrapper. +template +struct associated_immediate_executor, Executor> +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_forwarding_base +#endif // !defined(GENERATING_DOCUMENTATION) +{ + /// Forwards @c type to the associator specialisation for the unwrapped type + /// @c T. + typedef typename associated_immediate_executor::type type; + + /// Forwards the request to get the executor to the associator specialisation + /// for the unwrapped type @c T. + static auto get(reference_wrapper t, const Executor& ex) noexcept + -> decltype(associated_immediate_executor::get(t.get(), ex)) + { + return associated_immediate_executor::get(t.get(), ex); + } +}; + +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP diff --git a/inst/include/boost/asio/associator.hpp b/inst/include/boost/asio/associator.hpp index bc775b010..b0b5b44c0 100644 --- a/inst/include/boost/asio/associator.hpp +++ b/inst/include/boost/asio/associator.hpp @@ -2,7 +2,7 @@ // associator.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/inst/include/boost/asio/async_result.hpp b/inst/include/boost/asio/async_result.hpp index c25a2fae9..a45259518 100644 --- a/inst/include/boost/asio/async_result.hpp +++ b/inst/include/boost/asio/async_result.hpp @@ -2,7 +2,7 @@ // async_result.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,16 +17,13 @@ #include #include -#include #include namespace boost { namespace asio { -#if defined(BOOST_ASIO_HAS_CONCEPTS) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \ - && defined(BOOST_ASIO_HAS_DECLTYPE) +#if defined(BOOST_ASIO_HAS_CONCEPTS) namespace detail { @@ -40,8 +37,6 @@ struct is_completion_signature : true_type { }; -#if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct is_completion_signature : true_type { @@ -70,7 +65,6 @@ struct is_completion_signature : true_type }; # endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) template struct are_completion_signatures : false_type @@ -108,8 +102,6 @@ struct is_completion_handler_for { }; -#if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct is_completion_handler_for : integral_constant)> @@ -143,7 +135,6 @@ struct is_completion_handler_for }; # endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) template struct is_completion_handler_for @@ -175,8 +166,6 @@ BOOST_ASIO_CONCEPT completion_handler_for = ::boost::asio::completion_handler_for #else // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(BOOST_ASIO_HAS_DECLTYPE) #define BOOST_ASIO_COMPLETION_SIGNATURE typename #define BOOST_ASIO_COMPLETION_HANDLER_FOR(sig) typename @@ -184,8 +173,6 @@ BOOST_ASIO_CONCEPT completion_handler_for = #define BOOST_ASIO_COMPLETION_HANDLER_FOR3(sig0, sig1, sig2) typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(BOOST_ASIO_HAS_DECLTYPE) namespace detail { @@ -197,8 +184,6 @@ struct is_simple_completion_signature : false_type template struct simple_completion_signature; -#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - template struct is_simple_completion_signature : true_type { @@ -229,8 +214,6 @@ struct simple_completion_signature typedef R type(Args...); }; -#if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - template struct simple_completion_signature { @@ -264,197 +247,9 @@ struct simple_completion_signature }; # endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct is_simple_completion_signature : true_type -{ -}; - -#define BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct is_simple_completion_signature \ - : true_type \ - { \ - }; \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef BOOST_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 BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF - -#if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -template -struct simple_completion_signature -{ - typedef R type(); -}; - -#define BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature< \ - R(BOOST_ASIO_VARIADIC_TARGS(n)) &> \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(BOOST_ASIO_VARIADIC_TARGS(n)) &&> \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF - -# if defined(BOOST_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 BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF(n) \ - template \ - struct simple_completion_signature< \ - R(BOOST_ASIO_VARIADIC_TARGS(n)) noexcept> \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept> \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - \ - template \ - struct simple_completion_signature< \ - R(BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept> \ - { \ - typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)); \ - }; \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF) -#undef BOOST_ASIO_PRIVATE_SIMPLE_SIG_DEF - -# endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE) -#endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \ - || defined(GENERATING_DOCUMENTATION) - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TPARAMS \ - BOOST_ASIO_COMPLETION_SIGNATURE... Signatures - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TSPECPARAMS \ - BOOST_ASIO_COMPLETION_SIGNATURE... Signatures - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TARGS Signatures... - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TSIMPLEARGS \ - typename boost::asio::detail::simple_completion_signature< \ - Signatures>::type... - -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // || defined(GENERATING_DOCUMENTATION) - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TPARAMS \ - typename Sig0 = void, \ - typename Sig1 = void, \ - typename Sig2 = void -# define BOOST_ASIO_COMPLETION_SIGNATURES_TSPECPARAMS \ - typename Sig0, \ - typename Sig1, \ - typename Sig2 - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TARGS Sig0, Sig1, Sig2 - -# define BOOST_ASIO_COMPLETION_SIGNATURES_TSIMPLEARGS \ - typename ::boost::asio::detail::simple_completion_signature::type, \ - typename ::boost::asio::detail::simple_completion_signature::type, \ - typename ::boost::asio::detail::simple_completion_signature::type - -#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // || defined(GENERATING_DOCUMENTATION) - -template +template class completion_handler_async_result { public: @@ -469,56 +264,22 @@ class completion_handler_async_result { } -#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - template - static return_type initiate( - BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, - BOOST_ASIO_MOVE_ARG(Args)... args) - { - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token), - BOOST_ASIO_MOVE_CAST(Args)(args)...); - } - -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - - template - static return_type initiate( - BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_MOVE_ARG(RawCompletionToken) token) + static return_type initiate(Initiation&& initiation, + RawCompletionToken&& token, Args&&... args) { - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token)); + static_cast(initiation)( + static_cast(token), + static_cast(args)...); } -#define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - static return_type initiate( \ - BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \ - BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF) -#undef BOOST_ASIO_PRIVATE_INITIATE_DEF - -#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - private: completion_handler_async_result( - const completion_handler_async_result&) BOOST_ASIO_DELETED; + const completion_handler_async_result&) = delete; completion_handler_async_result& operator=( - const completion_handler_async_result&) BOOST_ASIO_DELETED; + const completion_handler_async_result&) = delete; }; } // namespace detail @@ -543,7 +304,8 @@ class completion_handler_async_result * The primary template assumes that the CompletionToken is the completion * handler. */ -template +template class async_result { public: @@ -568,70 +330,44 @@ class async_result /// obtain the value to be returned from the initiating function. template static return_type initiate( - BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, - BOOST_ASIO_MOVE_ARG(Args)... args); + Initiation&& initiation, + RawCompletionToken&& token, + Args&&... args); private: - async_result(const async_result&) BOOST_ASIO_DELETED; - async_result& operator=(const async_result&) BOOST_ASIO_DELETED; + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; }; #else // defined(GENERATING_DOCUMENTATION) -#if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template +template class async_result : - public conditional< - detail::are_simple_completion_signatures< - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS>::value, - detail::completion_handler_async_result< - CompletionToken, BOOST_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< - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS>::value, - detail::completion_handler_async_result< - CompletionToken, BOOST_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&) BOOST_ASIO_DELETED; - async_result& operator=(const async_result&) BOOST_ASIO_DELETED; + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; }; -#else // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -class async_result : - public detail::completion_handler_async_result< - CompletionToken, BOOST_ASIO_COMPLETION_SIGNATURES_TARGS> -{ -public: - explicit async_result(CompletionToken& h) - : detail::completion_handler_async_result< - CompletionToken, BOOST_ASIO_COMPLETION_SIGNATURES_TARGS>(h) - { - } - -private: - async_result(const async_result&) BOOST_ASIO_DELETED; - async_result& operator=(const async_result&) BOOST_ASIO_DELETED; -}; - -#endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS) - -template -class async_result +template +class async_result { // Empty. }; @@ -641,65 +377,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 boost::asio::async_result< - typename decay::type, - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS>::completion_handler_type - completion_handler_type; + decay_t, Signatures...>::completion_handler_type + completion_handler_type; -#if defined(BOOST_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(BOOST_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(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// A copy of, or reference to, a real handler object. -#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - typename conditional< + conditional_t< is_same::value, - completion_handler_type&, completion_handler_type>::type completion_handler; -#else // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - completion_handler_type completion_handler; -#endif // defined(BOOST_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, - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS> result; + async_result, Signatures...> result; }; namespace detail { -template -struct async_result_helper - : async_result::type, - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS> -{ -}; - struct async_result_memfns_base { void initiate(); @@ -725,11 +435,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, - BOOST_ASIO_COMPLETION_SIGNATURES_TARGS> + async_result, Signatures...> >(0)) != 1> { }; @@ -743,25 +453,6 @@ struct async_result_has_initiate_memfn void_or_deduced # define BOOST_ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \ void_or_deduced -#elif defined(_MSC_VER) && (_MSC_VER < 1500) -# define BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig>::return_type -# define BOOST_ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig0, sig1>::return_type -# define BOOST_ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig0, sig1, sig2>::return_type -#define BOOST_ASIO_HANDLER_TYPE(ct, sig) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig>::completion_handler_type -#define BOOST_ASIO_HANDLER_TYPE2(ct, sig0, sig1) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig0, sig1>::completion_handler_type -#define BOOST_ASIO_HANDLER_TYPE3(ct, sig0, sig1, sig2) \ - typename ::boost::asio::detail::async_result_helper< \ - ct, sig0, sig1, sig2>::completion_handler_type #else # define BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) \ typename ::boost::asio::async_result< \ @@ -824,7 +515,7 @@ struct async_result_has_initiate_memfn # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ auto # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) -#elif defined(BOOST_ASIO_HAS_DECLTYPE) +#else # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \ auto # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \ @@ -832,14 +523,6 @@ struct async_result_has_initiate_memfn # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ auto # define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) -> decltype expr -#else -# define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ct, sig) \ - BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) -# define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX2(ct, sig0, sig1) \ - BOOST_ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) -# define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX3(ct, sig0, sig1, sig2) \ - BOOST_ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) -# define BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(expr) #endif #if defined(GENERATING_DOCUMENTATION) @@ -849,20 +532,13 @@ struct async_result_has_initiate_memfn void_or_deduced # define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ void_or_deduced -#elif defined(BOOST_ASIO_HAS_DECLTYPE) +#else # define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \ decltype expr # define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \ decltype expr # define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ decltype expr -#else -# define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(ct, sig, expr) \ - BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) -# define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE2(ct, sig0, sig1, expr) \ - BOOST_ASIO_INITFN_RESULT_TYPE2(ct, sig0, sig1) -# define BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE3(ct, sig0, sig1, sig2, expr) \ - BOOST_ASIO_INITFN_RESULT_TYPE3(ct, sig0, sig1, sig2) #endif #if defined(GENERATING_DOCUMENTATION) @@ -871,326 +547,57 @@ template void_or_deduced async_initiate( - BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken), - BOOST_ASIO_MOVE_ARG(Args)... args); + Initiation&& initiation, + type_identity_t& token, + Args&&... args); -#elif defined(BOOST_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, - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, Signatures..., - (async_result::type, - Signatures...>::initiate(declval(), - declval(), - declval()...)))>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, - BOOST_ASIO_MOVE_ARG(Args)... args) -{ - return async_result::type, - Signatures...>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation), - BOOST_ASIO_MOVE_CAST(CompletionToken)(token), - BOOST_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, - BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signatures...)>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, - BOOST_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); - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(CompletionToken, - Signatures...))(completion.completion_handler), - BOOST_ASIO_MOVE_CAST(Args)(args)...); - - return completion.result.get(); -} - -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0>::value, - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(CompletionToken, Sig0, - (async_result::type, - Sig0>::initiate(declval(), - declval())))>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation), - BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1>::value, - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE2(CompletionToken, Sig0, Sig1, - (async_result::type, - Sig0, Sig1>::initiate(declval(), - declval())))>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0, Sig1>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation), - BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - detail::async_result_has_initiate_memfn< - CompletionToken, Sig0, Sig1, Sig2>::value, - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2, - (async_result::type, - Sig0, Sig1, Sig2>::initiate(declval(), - declval())))>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - return async_result::type, - Sig0, Sig1, Sig2>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation), - BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); -} - -template -inline typename constraint< - !detail::async_result_has_initiate_memfn< - CompletionToken, Sig0>::value, - BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Sig0)>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(BOOST_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, - BOOST_ASIO_INITFN_RESULT_TYPE2(CompletionToken, Sig0, Sig1)>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(BOOST_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, - BOOST_ASIO_INITFN_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2)>::type -async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token) -{ - async_completion completion(token); - - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( - BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE3(CompletionToken, - Sig0, Sig1, Sig2))(completion.completion_handler)); - - return completion.result.get(); -} +#endif // defined(GENERATING_DOCUMENTATION) -#define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0>::value, \ - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE( \ - CompletionToken, Sig0, \ - (async_result::type, \ - Sig0>::initiate( \ - declval(), \ - declval(), \ - BOOST_ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0>::initiate( \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation), \ - BOOST_ASIO_MOVE_CAST(CompletionToken)(token), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1>::value, \ - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE2( \ - CompletionToken, Sig0, Sig1, \ - (async_result::type, \ - Sig0, Sig1>::initiate( \ - declval(), \ - declval(), \ - BOOST_ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0, Sig1>::initiate( \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation), \ - BOOST_ASIO_MOVE_CAST(CompletionToken)(token), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1, Sig2>::value, \ - BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE3( \ - CompletionToken, Sig0, Sig1, Sig2, \ - (async_result::type, \ - Sig0, Sig1, Sig2>::initiate( \ - declval(), \ - declval(), \ - BOOST_ASIO_VARIADIC_MOVE_DECLVAL(n))))>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - return async_result::type, \ - Sig0, Sig1, Sig2>::initiate( \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation), \ - BOOST_ASIO_MOVE_CAST(CompletionToken)(token), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0>::value, \ - BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Sig0)>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \ - BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(CompletionToken, \ - Sig0))(completion.completion_handler), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1>::value, \ - BOOST_ASIO_INITFN_RESULT_TYPE2(CompletionToken, Sig0, Sig1)>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \ - BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE2(CompletionToken, \ - Sig0, Sig1))(completion.completion_handler), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - \ - template \ - inline typename constraint< \ - !detail::async_result_has_initiate_memfn< \ - CompletionToken, Sig0, Sig1, Sig2>::value, \ - BOOST_ASIO_INITFN_RESULT_TYPE3(CompletionToken, Sig0, Sig1, Sig2)>::type \ - async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \ - BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \ - BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \ - { \ - async_completion completion(token); \ - \ - BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \ - BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE3(CompletionToken, \ - Sig0, Sig1, Sig2))(completion.completion_handler), \ - BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ - \ - return completion.result.get(); \ - } \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF) -#undef BOOST_ASIO_PRIVATE_INITIATE_DEF - -#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -#if defined(BOOST_ASIO_HAS_CONCEPTS) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \ - && defined(BOOST_ASIO_HAS_DECLTYPE) +#if defined(BOOST_ASIO_HAS_CONCEPTS) namespace detail { @@ -1223,16 +630,12 @@ BOOST_ASIO_CONCEPT completion_token_for = ::boost::asio::completion_token_for #else // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(BOOST_ASIO_HAS_DECLTYPE) #define BOOST_ASIO_COMPLETION_TOKEN_FOR(sig) typename #define BOOST_ASIO_COMPLETION_TOKEN_FOR2(sig0, sig1) typename #define BOOST_ASIO_COMPLETION_TOKEN_FOR3(sig0, sig1, sig2) typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - // && defined(BOOST_ASIO_HAS_DECLTYPE) namespace detail { @@ -1246,21 +649,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(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) template class async_result @@ -1269,59 +672,16 @@ class async_result typedef detail::async_operation_probe_result return_type; template - static return_type initiate(BOOST_ASIO_MOVE_ARG(Initiation), - detail::async_operation_probe, BOOST_ASIO_MOVE_ARG(InitArgs)...) + static return_type initiate(Initiation&&, + detail::async_operation_probe, InitArgs&&...) { return return_type(); } }; -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -namespace detail { - -struct async_result_probe_base -{ - typedef detail::async_operation_probe_result return_type; - - template - static return_type initiate(BOOST_ASIO_MOVE_ARG(Initiation), - detail::async_operation_probe) - { - return return_type(); - } - -#define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \ - template \ - static return_type initiate(BOOST_ASIO_MOVE_ARG(Initiation), \ - detail::async_operation_probe, \ - BOOST_ASIO_VARIADIC_UNNAMED_MOVE_PARAMS(n)) \ - { \ - return return_type(); \ - } \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF) -#undef BOOST_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(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) #endif // !defined(GENERATING_DOCUMENTATION) -#if defined(GENERATION_DOCUMENTATION) +#if defined(GENERATING_DOCUMENTATION) /// The is_async_operation trait detects whether a type @c T and arguments /// @c Args... may be used to initiate an asynchronous operation. @@ -1336,7 +696,7 @@ struct is_async_operation : integral_constant { }; -#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) +#else // defined(GENERATING_DOCUMENTATION) template struct is_async_operation : @@ -1345,32 +705,9 @@ struct is_async_operation : { }; -#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) - -template -struct is_async_operation : - detail::is_async_operation_call< - T(detail::async_operation_probe)> -{ -}; - -#define BOOST_ASIO_PRIVATE_IS_ASYNC_OP_DEF(n) \ - template \ - struct is_async_operation : \ - detail::is_async_operation_call< \ - T(BOOST_ASIO_VARIADIC_TARGS(n), detail::async_operation_probe)> \ - { \ - }; \ - /**/ - BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_IS_ASYNC_OP_DEF) -#undef BOOST_ASIO_PRIVATE_IS_ASYNC_OP_DEF - -#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) +#endif // defined(GENERATING_DOCUMENTATION) -#if defined(BOOST_ASIO_HAS_CONCEPTS) \ - && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) +#if defined(BOOST_ASIO_HAS_CONCEPTS) template BOOST_ASIO_CONCEPT async_operation = is_async_operation::value; @@ -1385,7 +722,6 @@ BOOST_ASIO_CONCEPT async_operation = is_async_operation::value; ::boost::asio::async_operation #else // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) #define BOOST_ASIO_ASYNC_OPERATION(t) typename #define BOOST_ASIO_ASYNC_OPERATION1(t, a0) typename @@ -1393,37 +729,56 @@ BOOST_ASIO_CONCEPT async_operation = is_async_operation::value; #define BOOST_ASIO_ASYNC_OPERATION3(t, a0, a1, a2) typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) - // && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) namespace detail { struct completion_signature_probe {}; -template +template struct completion_signature_probe_result +{ + template