From 3476e303cf768f44ea5688ec81fb2d191805950f Mon Sep 17 00:00:00 2001 From: mat007 Date: Fri, 21 Jan 2011 15:24:00 +0000 Subject: [PATCH] Partially reverted 202 git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@203 860be788-9bd5-4423-9f1e-828f051e677b --- src/libraries/turtle/lambda.hpp | 49 ++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/libraries/turtle/lambda.hpp b/src/libraries/turtle/lambda.hpp index 641de0a..4f9aea7 100644 --- a/src/libraries/turtle/lambda.hpp +++ b/src/libraries/turtle/lambda.hpp @@ -13,7 +13,9 @@ #ifdef MOCK_USE_BOOST_BIND #include #else -#include +#include +#include +#include #endif #include @@ -21,12 +23,8 @@ namespace mock { namespace detail { -#ifdef MOCK_USE_BOOST_BIND - using boost::bind; -#else - using boost::phoenix::bind; -#endif +#ifdef MOCK_USE_BOOST_BIND template< typename Result, typename Signature > struct lambda { @@ -36,21 +34,21 @@ namespace detail template< typename T > static functor_type make_val( T t ) { - return bind( &do_identity< T >, t ); + return boost::bind( &do_identity< T >, t ); } template< typename T > static functor_type make_val( boost::reference_wrapper< T > t ) { - return bind( &do_ref_identity< T >, t.get_pointer() ); + return boost::bind( &do_ref_identity< T >, t.get_pointer() ); } template< typename T > static functor_type make_throw( T t ) { - return bind( &do_throw< T >, t ); + return boost::bind( &do_throw< T >, t ); } static functor_type make_nothing() { - return bind( &do_nothing ); + return boost::bind( &do_nothing ); } template< typename T > @@ -72,6 +70,37 @@ namespace detail { } }; + +#else + + template< typename Result, typename Signature > + struct lambda + { + typedef BOOST_DEDUCED_TYPENAME + boost::function< Signature > functor_type; + + template< typename T > + static functor_type make_val( T t ) + { + return boost::phoenix::val( t ); + } + template< typename T > + static functor_type make_val( boost::reference_wrapper< T > t ) + { + return *boost::phoenix::val( t.get_pointer() ); + } + template< typename T > + static functor_type make_throw( T t ) + { + return boost::phoenix::throw_( t ); + } + static functor_type make_nothing() + { + return boost::phoenix::nothing; + } + }; +#endif + } }