diff options
Diffstat (limited to 'boost/fiber/detail/wrap.hpp')
-rw-r--r-- | boost/fiber/detail/wrap.hpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/boost/fiber/detail/wrap.hpp b/boost/fiber/detail/wrap.hpp index 0369e61ee6..558de6bd94 100644 --- a/boost/fiber/detail/wrap.hpp +++ b/boost/fiber/detail/wrap.hpp @@ -10,8 +10,14 @@ #include <type_traits> #include <boost/config.hpp> +#if defined(BOOST_NO_CXX17_STD_INVOKE) #include <boost/context/detail/invoke.hpp> -#include <boost/context/execution_context.hpp> +#endif +#if (BOOST_EXECUTION_CONTEXT==1) +# include <boost/context/execution_context.hpp> +#else +# include <boost/context/continuation.hpp> +#endif #include <boost/fiber/detail/config.hpp> #include <boost/fiber/detail/data.hpp> @@ -36,9 +42,9 @@ private: public: wrapper( Fn1 && fn1, Fn2 && fn2, Tpl && tpl, boost::context::execution_context const& ctx) : - fn1_( std::move( fn1) ), - fn2_( std::move( fn2) ), - tpl_( std::move( tpl) ), + fn1_{ std::move( fn1) }, + fn2_{ std::move( fn2) }, + tpl_{ std::move( tpl) }, ctx_{ ctx } { } @@ -49,9 +55,11 @@ public: wrapper & operator=( wrapper && other) = default; void operator()( void * vp) { - boost::context::detail::invoke( - std::move( fn1_), - fn2_, tpl_, ctx_, vp); +#if defined(BOOST_NO_CXX17_STD_INVOKE) + boost::context::detail::invoke( std::move( fn1_), fn2_, tpl_, ctx_, vp); +#else + std::invoke( std::move( fn1_), fn2_, tpl_, ctx_, vp); +#endif } }; @@ -59,11 +67,11 @@ template< typename Fn1, typename Fn2, typename Tpl > wrapper< Fn1, Fn2, Tpl > wrap( Fn1 && fn1, Fn2 && fn2, Tpl && tpl, boost::context::execution_context const& ctx) { - return wrapper< Fn1, Fn2, Tpl >( + return wrapper< Fn1, Fn2, Tpl >{ std::forward< Fn1 >( fn1), std::forward< Fn2 >( fn2), std::forward< Tpl >( tpl), - ctx); + ctx }; } #else template< typename Fn1, typename Fn2, typename Tpl > @@ -75,9 +83,9 @@ private: public: wrapper( Fn1 && fn1, Fn2 && fn2, Tpl && tpl) : - fn1_( std::move( fn1) ), - fn2_( std::move( fn2) ), - tpl_( std::move( tpl) ) { + fn1_{ std::move( fn1) }, + fn2_{ std::move( fn2) }, + tpl_{ std::move( tpl) } { } wrapper( wrapper const&) = delete; @@ -86,24 +94,31 @@ public: wrapper( wrapper && other) = default; wrapper & operator=( wrapper && other) = default; - boost::context::execution_context< data_t * > - operator()( boost::context::execution_context< data_t * > && ctx, data_t * dp) { + boost::context::continuation + operator()( boost::context::continuation && c) { +#if defined(BOOST_NO_CXX17_STD_INVOKE) return boost::context::detail::invoke( std::move( fn1_), fn2_, tpl_, - std::forward< boost::context::execution_context< data_t * > >( ctx), - dp); + std::forward< boost::context::continuation >( c) ); +#else + return std::invoke( + std::move( fn1_), + fn2_, + tpl_, + std::forward< boost::context::continuation >( c) ); +#endif } }; template< typename Fn1, typename Fn2, typename Tpl > wrapper< Fn1, Fn2, Tpl > wrap( Fn1 && fn1, Fn2 && fn2, Tpl && tpl) { - return wrapper< Fn1, Fn2, Tpl >( + return wrapper< Fn1, Fn2, Tpl >{ std::forward< Fn1 >( fn1), std::forward< Fn2 >( fn2), - std::forward< Tpl >( tpl) ); + std::forward< Tpl >( tpl) }; } #endif |