mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Refactoring
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@682 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
392240a87c
commit
616692f3e5
2 changed files with 17 additions and 17 deletions
|
|
@ -73,18 +73,18 @@ namespace detail
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
void returns( const Value& v )
|
void returns( const Value& v )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( boost::ref( v_.store( v ) ) );
|
f_ = lambda_type::make_ref( boost::ref( v_.store( v ) ) );
|
||||||
}
|
}
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
void returns( Value* v )
|
void returns( Value* v )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val(
|
f_ = lambda_type::make_ref(
|
||||||
boost::ref( v_.store( result_type( v ) ) ) );
|
boost::ref( v_.store( result_type( v ) ) ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( const boost::reference_wrapper< Y >& r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_ref( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
|
|
@ -132,7 +132,7 @@ namespace detail
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( const boost::reference_wrapper< Y >& r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_ref( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
void calls( const functor_type& f )
|
void calls( const functor_type& f )
|
||||||
|
|
@ -206,7 +206,7 @@ namespace detail
|
||||||
action( const action& rhs )
|
action( const action& rhs )
|
||||||
: v_( const_cast< action& >( rhs ).v_.release() )
|
: v_( const_cast< action& >( rhs ).v_.release() )
|
||||||
, f_( v_.get()
|
, f_( v_.get()
|
||||||
? lambda_type::make_val( boost::ref( v_ ) )
|
? lambda_type::make_ref( boost::ref( v_ ) )
|
||||||
: rhs.f_ )
|
: rhs.f_ )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
@ -239,18 +239,18 @@ namespace detail
|
||||||
void set( std::auto_ptr< Y > r )
|
void set( std::auto_ptr< Y > r )
|
||||||
{
|
{
|
||||||
v_ = r;
|
v_ = r;
|
||||||
f_ = lambda_type::make_val( boost::ref( v_ ) );
|
f_ = lambda_type::make_ref( boost::ref( v_ ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void set( const boost::reference_wrapper< Y >& r )
|
void set( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_ref( r );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void set( Y* r )
|
void set( Y* r )
|
||||||
{
|
{
|
||||||
v_.reset( r );
|
v_.reset( r );
|
||||||
f_ = lambda_type::make_val( boost::ref( v_ ) );
|
f_ = lambda_type::make_ref( boost::ref( v_ ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr< Result > v_;
|
std::auto_ptr< Result > v_;
|
||||||
|
|
|
||||||
|
|
@ -37,18 +37,17 @@ namespace detail
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_val( T t )
|
static functor_type make_val( T t )
|
||||||
{
|
{
|
||||||
return detail::bind( &do_identity< T >, t );
|
return detail::bind( &do_val< T >, t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_val( const boost::reference_wrapper< T >& t )
|
static functor_type make_ref( const boost::reference_wrapper< T >& t )
|
||||||
{
|
{
|
||||||
return detail::bind(
|
return detail::bind( &do_ref< T >, t.get_pointer() );
|
||||||
&do_ref_identity< T >, t.get_pointer() );
|
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_move( T& t )
|
static functor_type make_move( T& t )
|
||||||
{
|
{
|
||||||
return detail::bind( &do_move< T >, boost::ref( t ) );
|
return detail::bind( &do_move< T >, &t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static functor_type make_throw( T t )
|
static functor_type make_throw( T t )
|
||||||
|
|
@ -60,18 +59,19 @@ namespace detail
|
||||||
return detail::bind( &do_nothing );
|
return detail::bind( &do_nothing );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static T do_identity( T t )
|
static T do_val( T t )
|
||||||
{
|
{
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static T do_move( T& t )
|
static T do_move( T* t )
|
||||||
{
|
{
|
||||||
return boost::move( t );
|
return boost::move( *t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static T& do_ref_identity( T* t )
|
static T& do_ref( T* t )
|
||||||
{
|
{
|
||||||
return *t;
|
return *t;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue