mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Return actions now accept by copy types derived from abstract base types
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@612 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
1ddf17d1c1
commit
02e2b4bbfd
2 changed files with 40 additions and 4 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "lambda.hpp"
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
|
@ -34,12 +35,22 @@ namespace detail
|
|||
|
||||
public:
|
||||
template< typename Value >
|
||||
void returns( Value v )
|
||||
void returns( Value v,
|
||||
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
||||
boost::is_convertible< Value, result_type > >::type* = 0 )
|
||||
{
|
||||
r_.reset( new result_type( v ) );
|
||||
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
||||
}
|
||||
template< typename Value >
|
||||
void returns( Value v,
|
||||
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
||||
boost::is_convertible< Value, result_type > >::type* = 0 )
|
||||
{
|
||||
// if an error is generated by the line below it means a value
|
||||
// passed to 'returns' was of the wrong type as it cannot be
|
||||
// used to copy construct a Result
|
||||
r_.reset( new result_type( v ) );
|
||||
r_.reset( new Value( v ) );
|
||||
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
||||
}
|
||||
template< typename Y >
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue