From 4d2a30b176975acddda404780b93c35bd5bd2755 Mon Sep 17 00:00:00 2001 From: mat007 Date: Fri, 22 Jan 2010 23:17:41 +0000 Subject: [PATCH] Tuned mock::retrieve to provide a better error message when retrieving const data into non-const pointer git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@98 860be788-9bd5-4423-9f1e-828f051e677b --- src/libraries/turtle/functional.hpp | 2 +- src/tests/turtle_test/constraint_test.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libraries/turtle/functional.hpp b/src/libraries/turtle/functional.hpp index 3b0b2df..d319e93 100644 --- a/src/libraries/turtle/functional.hpp +++ b/src/libraries/turtle/functional.hpp @@ -138,7 +138,7 @@ namespace detail template< typename Y > bool operator()( const Y& y, BOOST_DEDUCED_TYPENAME boost::disable_if< - boost::is_convertible< Y*, T >, Y >::type* = 0 ) const + boost::is_convertible< const Y*, T >, Y >::type* = 0 ) const { t_.get() = y; return true; diff --git a/src/tests/turtle_test/constraint_test.cpp b/src/tests/turtle_test/constraint_test.cpp index e9a64af..f481e64 100644 --- a/src/tests/turtle_test/constraint_test.cpp +++ b/src/tests/turtle_test/constraint_test.cpp @@ -87,6 +87,12 @@ BOOST_AUTO_TEST_CASE( retrieve ) BOOST_CHECK( mock::retrieve( i ).functor_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } + { + const int* i = 0; + int j = 1; + BOOST_CHECK( mock::retrieve( i ).functor_( j ) ); + BOOST_CHECK_EQUAL( i, &j ); + } { int* i = 0; int j = 1;