mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
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
This commit is contained in:
parent
e07c59c436
commit
4d2a30b176
2 changed files with 7 additions and 1 deletions
|
|
@ -138,7 +138,7 @@ namespace detail
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
bool operator()( const Y& y,
|
bool operator()( const Y& y,
|
||||||
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
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;
|
t_.get() = y;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,12 @@ BOOST_AUTO_TEST_CASE( retrieve )
|
||||||
BOOST_CHECK( mock::retrieve( i ).functor_( j ) );
|
BOOST_CHECK( mock::retrieve( i ).functor_( j ) );
|
||||||
BOOST_CHECK_EQUAL( i, &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* i = 0;
|
||||||
int j = 1;
|
int j = 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue