Fixed phoenix and lambda functors logging

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@432 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-03-24 06:23:47 +00:00
parent bfab83e7c2
commit 2768c8b172
2 changed files with 31 additions and 3 deletions

View file

@ -12,6 +12,7 @@
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/detail/container_fwd.hpp> #include <boost/detail/container_fwd.hpp>
#include <boost/function_types/is_callable_builtin.hpp> #include <boost/function_types/is_callable_builtin.hpp>
#include <boost/utility/addressof.hpp>
#include <ostream> #include <ostream>
#include <memory> #include <memory>
@ -20,6 +21,14 @@ namespace boost
template< typename T > class shared_ptr; template< typename T > class shared_ptr;
template< typename T > class weak_ptr; template< typename T > class weak_ptr;
namespace phoenix
{
template< typename T > struct actor;
}
namespace lambda
{
template< typename T > struct lambda_functor;
}
namespace assign_detail namespace assign_detail
{ {
template< typename T > class generic_list; template< typename T > class generic_list;
@ -64,7 +73,7 @@ namespace detail3
struct holder_imp : holder struct holder_imp : holder
{ {
explicit holder_imp( const T& t ) explicit holder_imp( const T& t )
: t_( &t ) : t_( boost::addressof( t ) )
{} {}
virtual void serialize( std::ostream& s ) const virtual void serialize( std::ostream& s ) const
{ {
@ -149,7 +158,7 @@ namespace detail2
struct formatter struct formatter
{ {
explicit formatter( const T& t ) explicit formatter( const T& t )
: t_( &t ) : t_( boost::addressof( t ) )
{} {}
void serialize( stream& s ) const void serialize( stream& s ) const
{ {
@ -269,7 +278,16 @@ namespace detail
{ {
return s << mock::format( t.lock() ); return s << mock::format( t.lock() );
} }
template< typename T >
stream& operator<<( stream& s, boost::lambda::lambda_functor< T > )
{
return s << '?';
}
template< typename T >
stream& operator<<( stream& s, boost::phoenix::actor< T > )
{
return s << '?';
}
template< typename T > template< typename T >
BOOST_DEDUCED_TYPENAME boost::enable_if< BOOST_DEDUCED_TYPENAME boost::enable_if<
boost::function_types::is_callable_builtin< T >, boost::function_types::is_callable_builtin< T >,

View file

@ -12,8 +12,16 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp> #include <boost/weak_ptr.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#ifdef _MSC_VER
#pragma warning( push, 0 )
#endif
#include <boost/spirit/home/phoenix.hpp>
#include <boost/spirit/home/phoenix/bind.hpp> #include <boost/spirit/home/phoenix/bind.hpp>
#include <boost/lambda/bind.hpp> #include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#ifdef _MSC_VER
#pragma warning( pop )
#endif
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <vector> #include <vector>
#include <deque> #include <deque>
@ -578,6 +586,7 @@ namespace
BOOST_AUTO_TEST_CASE( boost_phoenix_functor_yields_question_mark_when_serialized ) BOOST_AUTO_TEST_CASE( boost_phoenix_functor_yields_question_mark_when_serialized )
{ {
BOOST_CHECK_EQUAL( "?", to_string( boost::phoenix::bind( &some_function ) ) ); BOOST_CHECK_EQUAL( "?", to_string( boost::phoenix::bind( &some_function ) ) );
BOOST_CHECK_EQUAL( "?", to_string( boost::phoenix::arg_names::_1 < 42 ) );
} }
BOOST_AUTO_TEST_CASE( boost_bind_functor_yields_question_mark_when_serialized ) BOOST_AUTO_TEST_CASE( boost_bind_functor_yields_question_mark_when_serialized )
@ -588,4 +597,5 @@ BOOST_AUTO_TEST_CASE( boost_bind_functor_yields_question_mark_when_serialized )
BOOST_AUTO_TEST_CASE( boost_lambda_functor_yields_question_mark_when_serialized ) BOOST_AUTO_TEST_CASE( boost_lambda_functor_yields_question_mark_when_serialized )
{ {
BOOST_CHECK_EQUAL( "?", to_string( boost::lambda::bind( &some_function ) ) ); BOOST_CHECK_EQUAL( "?", to_string( boost::lambda::bind( &some_function ) ) );
BOOST_CHECK_EQUAL( "?", to_string( boost::lambda::_1 < 42 ) );
} }