no assignment of captured_context with std::tie()

This commit is contained in:
Oliver Kowalke 2016-01-03 17:43:13 +01:00
parent 57562ffb2a
commit 79ff178d7e
2 changed files with 27 additions and 27 deletions

View File

@ -37,7 +37,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
other{ nullptr }, other{ nullptr },
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS) #if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
ctx{ std::allocator_arg, palloc, salloc, ctx{ std::allocator_arg, palloc, salloc,
std::move( std::move(
std::bind( std::bind(
[this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable { [this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
@ -85,9 +85,9 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
bvalid{ false }, bvalid{ false },
storage{} { storage{} {
// enter coroutine-fn in order to have first value available after ctor (of `*this`) returns // enter coroutine-fn in order to have first value available after ctor (of `*this`) returns
void * data = nullptr; auto result = ctx();
std::tie( ctx, data) = ctx(); ctx = std::move( std::get< 0 >( result) );
set( static_cast< T * >( data) ); set( static_cast< T * >( std::get< 1 >( result) ) );
} }
template< typename T > template< typename T >
@ -111,9 +111,9 @@ pull_coroutine< T >::control_block::~control_block() {
template< typename T > template< typename T >
void void
pull_coroutine< T >::control_block::resume() { pull_coroutine< T >::control_block::resume() {
void * data; auto result = ctx();
std::tie( ctx, data) = ctx(); ctx = std::move( std::get< 0 >( result) );
set( static_cast< T * >( data) ); set( static_cast< T * >( std::get< 1 >( result) ) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -156,7 +156,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
other{ nullptr }, other{ nullptr },
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS) #if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
ctx{ std::allocator_arg, palloc, salloc, ctx{ std::allocator_arg, palloc, salloc,
std::move( std::move(
std::bind( std::bind(
[this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable { [this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
@ -203,9 +203,9 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
except{}, except{},
t{ nullptr } { t{ nullptr } {
// enter coroutine-fn in order to have first value available after ctor (of `*this`) returns // enter coroutine-fn in order to have first value available after ctor (of `*this`) returns
void * data = nullptr; auto result = ctx();
std::tie( ctx, data) = ctx(); ctx = std::move( std::get< 0 >( result) );
t = static_cast< T * >( data); t = static_cast< T * >( std::get< 1 >( result) );
} }
template< typename T > template< typename T >
@ -220,9 +220,9 @@ pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T
template< typename T > template< typename T >
void void
pull_coroutine< T & >::control_block::resume() { pull_coroutine< T & >::control_block::resume() {
void * data; auto result = ctx();
std::tie( ctx, data) = ctx(); ctx = std::move( std::get< 0 >( result) );
t = static_cast< T * >( data); t = static_cast< T * >( std::get< 1 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -249,7 +249,7 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
other{ nullptr }, other{ nullptr },
#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS) #if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
ctx{ std::allocator_arg, palloc, salloc, ctx{ std::allocator_arg, palloc, salloc,
std::move( std::move(
std::bind( std::bind(
[this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable { [this]( typename std::decay< Fn >::type & fn_, boost::context::captured_context ctx, void *) mutable {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
@ -295,8 +295,8 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
#endif #endif
except{} { except{} {
// enter coroutine-fn in order to have first value available after ctor (of `*this`) returns // enter coroutine-fn in order to have first value available after ctor (of `*this`) returns
void * ignored = nullptr; auto result = ctx();
std::tie( ctx, ignored) = ctx(); ctx = std::move( std::get< 0 >( result) );
} }
inline inline
@ -310,8 +310,8 @@ pull_coroutine< void >::control_block::control_block( push_coroutine< void >::co
inline inline
void void
pull_coroutine< void >::control_block::resume() { pull_coroutine< void >::control_block::resume() {
void * ignored; auto result = ctx();
std::tie( ctx, ignored) = ctx(); ctx = std::move( std::get< 0 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }

View File

@ -99,8 +99,8 @@ template< typename T >
void void
push_coroutine< T >::control_block::resume( T const& data) { push_coroutine< T >::control_block::resume( T const& data) {
// pass an pointer to other context // pass an pointer to other context
void * ignored; auto result = ctx( const_cast< T * >( & data) );
std::tie( ctx, ignored) = ctx( const_cast< T * >( & data) ); ctx = std::move( std::get< 0 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -110,8 +110,8 @@ template< typename T >
void void
push_coroutine< T >::control_block::resume( T && data) { push_coroutine< T >::control_block::resume( T && data) {
// pass an pointer to other context // pass an pointer to other context
void * ignored; auto result = ctx( std::addressof( data) );
std::tie( ctx, ignored) = ctx( std::addressof( data) ); ctx = std::move( std::get< 0 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -196,8 +196,8 @@ template< typename T >
void void
push_coroutine< T & >::control_block::resume( T & t) { push_coroutine< T & >::control_block::resume( T & t) {
// pass an pointer to other context // pass an pointer to other context
void * ignored; auto result = ctx( const_cast< typename std::remove_const< T >::type * >( std::addressof( t) ) );
std::tie( ctx, ignored) = ctx( const_cast< typename std::remove_const< T >::type * >( std::addressof( t) ) ); ctx = std::move( std::get< 0 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -275,8 +275,8 @@ push_coroutine< void >::control_block::control_block( pull_coroutine< void >::co
inline inline
void void
push_coroutine< void >::control_block::resume() { push_coroutine< void >::control_block::resume() {
void * ignored; auto result = ctx();
std::tie( ctx, ignored) = ctx(); ctx = std::move( std::get< 0 >( result) );
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }