Fixed a bug preventing non-const pointer to be logged properly

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@304 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2011-05-01 19:47:48 +00:00
parent 103eed82cb
commit 5ad7562d65
3 changed files with 43 additions and 7 deletions

View file

@ -105,11 +105,7 @@ namespace detail3
}
template< typename T >
BOOST_DEDUCED_TYPENAME boost::disable_if<
boost::function_types::is_callable_builtin< T >,
stream&
>::type
operator<<( stream& s, const T& t )
stream& operator<<( stream& s, const T& t )
{
using namespace detail3;
*s.s_ << t;
@ -257,9 +253,19 @@ namespace detail
boost::function_types::is_callable_builtin< T >,
stream&
>::type
operator<<( stream& s, const T& )
operator<<( stream& s, T* )
{
return s << '?';
return s << '?';
}
template< typename T >
BOOST_DEDUCED_TYPENAME boost::disable_if<
boost::function_types::is_callable_builtin< T >,
stream&
>::type
operator<<( stream& s, T* t )
{
*s.s_ << t;
return s;
}
}

View file

@ -9,6 +9,7 @@
#define MOCK_USE_CONVERSIONS
#include <turtle/log.hpp>
#include <boost/assign.hpp>
#include <boost/lexical_cast.hpp>
#include <vector>
#include <deque>
#include <list>
@ -30,6 +31,20 @@ namespace
}
}
BOOST_AUTO_TEST_CASE( pointer_yields_its_value_when_serialized_with_conversions )
{
{
int i = 0;
BOOST_CHECK_NE( "?", to_string( &i ) );
BOOST_CHECK_EQUAL( boost::lexical_cast< std::string >( &i ), to_string( &i ) );
}
{
const int i = 0;
BOOST_CHECK_NE( "?", to_string( &i ) );
BOOST_CHECK_EQUAL( boost::lexical_cast< std::string >( &i ), to_string( &i ) );
}
}
BOOST_AUTO_TEST_CASE( base_type_yields_its_value_when_serialized_with_conversions )
{
BOOST_CHECK_EQUAL( "42", to_string( 42 ) );

View file

@ -8,6 +8,7 @@
#include <turtle/log.hpp>
#include <boost/assign.hpp>
#include <boost/lexical_cast.hpp>
#include <vector>
#include <deque>
#include <list>
@ -29,6 +30,20 @@ namespace
}
}
BOOST_AUTO_TEST_CASE( pointer_yields_its_value_when_serialized_without_conversions )
{
{
int i = 0;
BOOST_CHECK_NE( "?", to_string( &i ) );
BOOST_CHECK_EQUAL( boost::lexical_cast< std::string >( &i ), to_string( &i ) );
}
{
const int i = 0;
BOOST_CHECK_NE( "?", to_string( &i ) );
BOOST_CHECK_EQUAL( boost::lexical_cast< std::string >( &i ), to_string( &i ) );
}
}
BOOST_AUTO_TEST_CASE( base_type_yields_its_value_when_serialized_without_conversions )
{
BOOST_CHECK_EQUAL( "42", to_string( 42 ) );