Merged revision(s) 81780 from trunk: Use explicit operator bool when available; add nullptr support to shared_ptr. Fixes #4116.

[SVN r81862]
This commit is contained in:
Peter Dimov
2012-12-11 18:35:21 +00:00
parent b306c9751f
commit d42ce87557
9 changed files with 386 additions and 3 deletions

View File

@@ -0,0 +1,78 @@
//
// sp_zero_compare_test.cpp - == 0, != 0
//
// Copyright 2012 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
struct W
{
};
void intrusive_ptr_add_ref( W* )
{
}
void intrusive_ptr_release( W* )
{
}
int main()
{
{
boost::scoped_ptr<int> p;
BOOST_TEST( p == 0 );
BOOST_TEST( 0 == p );
BOOST_TEST( !( p != 0 ) );
BOOST_TEST( !( 0 != p ) );
}
{
boost::scoped_array<int> p;
BOOST_TEST( p == 0 );
BOOST_TEST( 0 == p );
BOOST_TEST( !( p != 0 ) );
BOOST_TEST( !( 0 != p ) );
}
{
boost::shared_ptr<int> p;
BOOST_TEST( p == 0 );
BOOST_TEST( 0 == p );
BOOST_TEST( !( p != 0 ) );
BOOST_TEST( !( 0 != p ) );
}
{
boost::shared_array<int> p;
BOOST_TEST( p == 0 );
BOOST_TEST( 0 == p );
BOOST_TEST( !( p != 0 ) );
BOOST_TEST( !( 0 != p ) );
}
{
boost::intrusive_ptr<W> p;
BOOST_TEST( p == 0 );
BOOST_TEST( 0 == p );
BOOST_TEST( !( p != 0 ) );
BOOST_TEST( !( 0 != p ) );
}
return boost::report_errors();
}