disable passing non type for yielding to

This commit is contained in:
Oliver Kowalke
2014-02-08 10:37:35 +01:00
parent 81c94d05f7
commit 0557ffdc6b
2 changed files with 56 additions and 16 deletions

View File

@@ -145,22 +145,22 @@ public:
}
template< typename X >
R * yield_to( symmetric_coroutine_impl< X > * other, X x)
R * yield_to( symmetric_coroutine_impl< X > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X >::param_type to( & x);
typename symmetric_coroutine_impl< X >::param_type to( const_cast< X * >( & x) );
return yield_to_( other, & to);
}
template< typename X >
R * yield_to( symmetric_coroutine_impl< X & > * other, X & x)
R * yield_to( symmetric_coroutine_impl< X & > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X & >::param_type to( & x);
typename symmetric_coroutine_impl< X & >::param_type to( const_cast< X * >( & x) );
return yield_to_( other, & to);
}
@@ -281,22 +281,22 @@ public:
}
template< typename X >
R * yield_to( symmetric_coroutine_impl< X > * other, X x)
R * yield_to( symmetric_coroutine_impl< X > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X >::param_type to( & x);
typename symmetric_coroutine_impl< X >::param_type to( const_cast< X * >( & x) );
return yield_to_( other, & to);
}
template< typename X >
R * yield_to( symmetric_coroutine_impl< X & > * other, X & x)
R * yield_to( symmetric_coroutine_impl< X & > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X & >::param_type to( & x);
typename symmetric_coroutine_impl< X & >::param_type to( const_cast< X * >( & x) );
return yield_to_( other, & to);
}
@@ -418,12 +418,22 @@ public:
}
template< typename X >
void yield_to( symmetric_coroutine_impl< X & > * other, X & x)
void yield_to( symmetric_coroutine_impl< X > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X & >::param_type to( & x);
typename symmetric_coroutine_impl< X >::param_type to( const_cast< X * >( & x) );
yield_to_( other, & to);
}
template< typename X >
void yield_to( symmetric_coroutine_impl< X & > * other, X const& x)
{
BOOST_ASSERT( ! is_complete() );
BOOST_ASSERT( ! other->is_complete() );
typename symmetric_coroutine_impl< X & >::param_type to( const_cast< X * >( & x) );
yield_to_( other, & to);
}

View File

@@ -12,6 +12,8 @@
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/move/move.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/utility/explicit_operator_bool.hpp>
#include <boost/coroutine/detail/config.hpp>
@@ -38,6 +40,8 @@ private:
typedef parameters< R > param_type;
typedef symmetric_coroutine_impl< R > impl_type;
struct dummy {};
BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_yield)
impl_type * impl_;
@@ -86,7 +90,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type & x)
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type const& x,
typename disable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);
@@ -95,7 +103,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other)
symmetric_coroutine_yield & operator()( Coro & other,
typename enable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);
@@ -171,7 +183,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type & x)
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type const& x,
typename disable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);
@@ -180,7 +196,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other)
symmetric_coroutine_yield & operator()( Coro & other,
typename enable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);
@@ -206,6 +226,8 @@ private:
typedef parameters< void > param_type;
typedef symmetric_coroutine_impl< void > impl_type;
struct dummy {};
BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_yield)
impl_type * impl_;
@@ -245,7 +267,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type & x)
symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type const& x,
typename disable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);
@@ -254,7 +280,11 @@ public:
}
template< typename Coro >
symmetric_coroutine_yield & operator()( Coro & other)
symmetric_coroutine_yield & operator()( Coro & other,
typename enable_if<
is_same< typename Coro::value_type, void >,
dummy*
>::type = 0)
{
BOOST_ASSERT( other);