Remove uses of BOOST_NO_CXX11_NULLPTR

This commit is contained in:
Peter Dimov
2024-09-24 19:05:48 +03:00
parent bd0419c290
commit 569b07b91c
14 changed files with 45 additions and 189 deletions

View File

@ -78,10 +78,8 @@ public:
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
sp_alloc_ptr(std::nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator*() const {
return *p_;
@ -133,10 +131,8 @@ public:
: p_(p)
, n_(n) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
sp_alloc_ptr(std::nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
@ -184,10 +180,8 @@ public:
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
sp_alloc_ptr(std::nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
@ -237,18 +231,17 @@ operator!=(const sp_alloc_ptr<T, P>& lhs, const sp_alloc_ptr<T, P>& rhs)
return !(lhs == rhs);
}
#if !defined(BOOST_NO_CXX11_NULLPTR)
template<class T, class P>
inline bool
operator==(const sp_alloc_ptr<T, P>& lhs,
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
std::nullptr_t) BOOST_SP_NOEXCEPT
{
return !lhs.ptr();
}
template<class T, class P>
inline bool
operator==(detail::sp_nullptr_t,
operator==(std::nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !rhs.ptr();
@ -257,19 +250,18 @@ operator==(detail::sp_nullptr_t,
template<class T, class P>
inline bool
operator!=(const sp_alloc_ptr<T, P>& lhs,
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
std::nullptr_t) BOOST_SP_NOEXCEPT
{
return !!lhs.ptr();
}
template<class T, class P>
inline bool
operator!=(detail::sp_nullptr_t,
operator!=(std::nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !!rhs.ptr();
}
#endif
template<class A>
inline void

View File

@ -60,14 +60,10 @@ public:
d_( p );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT
void operator()( std::nullptr_t p ) BOOST_SP_NOEXCEPT
{
d_( p );
}
#endif
};
template<> class local_sp_deleter<void>

View File

@ -18,8 +18,6 @@
#include <boost/config.hpp>
#include <cstddef>
#if !defined( BOOST_NO_CXX11_NULLPTR )
namespace boost
{
@ -40,6 +38,4 @@ namespace detail
} // namespace boost
#endif // !defined( BOOST_NO_CXX11_NULLPTR )
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED

View File

@ -212,30 +212,26 @@ template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const
return a != b.get();
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( intrusive_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( intrusive_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) BOOST_SP_NOEXCEPT
{
return std::less<T *>()(a.get(), b.get());

View File

@ -140,14 +140,10 @@ public:
{
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
BOOST_CONSTEXPR local_shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn( 0 )
BOOST_CONSTEXPR local_shared_ptr( std::nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn( 0 )
{
}
#endif
// internal constructor, used by make_shared
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, element_type * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
{
@ -164,29 +160,21 @@ public:
boost::detail::lsp_deleter_construct( this, p, d, pn );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class D> local_shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( 0 )
template<class D> local_shared_ptr( std::nullptr_t p, D d ): px( p ), pn( 0 )
{
boost::detail::lsp_deleter_construct( this, p, d, pn );
}
#endif
template<class Y, class D, class A> local_shared_ptr( Y * p, D d, A a ): px( p ), pn( 0 )
{
boost::detail::lsp_allocator_construct( this, p, d, a, pn );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class D, class A> local_shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( 0 )
template<class D, class A> local_shared_ptr( std::nullptr_t p, D d, A a ): px( p ), pn( 0 )
{
boost::detail::lsp_allocator_construct( this, p, d, a, pn );
}
#endif
// construction from shared_ptr
template<class Y> local_shared_ptr( shared_ptr<Y> const & r,
@ -349,17 +337,13 @@ public:
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
local_shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
local_shared_ptr & operator=( std::nullptr_t ) BOOST_SP_NOEXCEPT
{
local_shared_ptr().swap(*this);
return *this;
}
#endif
#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y, class D>
local_shared_ptr & operator=( std::unique_ptr<Y, D> && r )
@ -513,30 +497,26 @@ template<class T, class U> inline bool operator!=( local_shared_ptr<T> const & a
return a.get() != b.get();
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( local_shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( local_shared_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( local_shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( local_shared_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T, class U> inline bool operator==( local_shared_ptr<T> const & a, shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();

View File

@ -98,30 +98,26 @@ public:
}
};
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( scoped_array<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( scoped_array<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);

View File

@ -122,30 +122,26 @@ public:
}
};
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( scoped_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( scoped_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);

View File

@ -58,14 +58,10 @@ public:
{
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
shared_array( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
shared_array( std::nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
#endif
template<class Y>
explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() )
{
@ -237,30 +233,26 @@ template<class T> inline bool operator!=(shared_array<T> const & a, shared_array
return a.get() != b.get();
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( shared_array<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( shared_array<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_NOEXCEPT
{
return std::less<T*>()(a.get(), b.get());

View File

@ -283,14 +283,10 @@ public:
{
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
BOOST_CONSTEXPR shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
BOOST_CONSTEXPR shared_ptr( std::nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
#endif
BOOST_CONSTEXPR shared_ptr( boost::detail::sp_internal_constructor_tag, element_type * px_, boost::detail::shared_count const & pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
{
}
@ -331,22 +327,18 @@ public:
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, static_cast< D&& >( d ) )
template<class D> shared_ptr( std::nullptr_t p, D d ): px( p ), pn( p, static_cast< D&& >( d ) )
{
}
#else
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d )
template<class D> shared_ptr( std::nullptr_t p, D d ): px( p ), pn( p, d )
{
}
#endif
#endif
// As above, but with allocator. A's copy constructor shall not throw.
@ -367,24 +359,20 @@ public:
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, static_cast< D&& >( d ), a )
template<class D, class A> shared_ptr( std::nullptr_t p, D d, A a ): px( p ), pn( p, static_cast< D&& >( d ), a )
{
}
#else
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a )
template<class D, class A> shared_ptr( std::nullptr_t p, D d, A a ): px( p ), pn( p, d, a )
{
}
#endif
#endif
// generated copy constructor, destructor are fine...
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
@ -627,16 +615,12 @@ public:
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
shared_ptr & operator=( std::nullptr_t ) BOOST_SP_NOEXCEPT
{
this_type().swap(*this);
return *this;
}
#endif
void reset() BOOST_SP_NOEXCEPT
{
this_type().swap(*this);
@ -803,30 +787,26 @@ template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, share
return a.get() != b.get();
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( shared_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator==( std::nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( shared_ptr<T> const & p, std::nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template<class T> inline bool operator!=( std::nullptr_t, shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
#endif
template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a.owner_before( b );

View File

@ -78,8 +78,6 @@ static void default_constructor()
static void nullptr_constructor()
{
#if !defined( BOOST_NO_CXX11_NULLPTR )
{
boost::local_shared_ptr<int> p( nullptr );
@ -112,8 +110,6 @@ static void nullptr_constructor()
BOOST_TEST_EQ( p.get(), static_cast<void*>(0) );
BOOST_TEST_EQ( p.local_use_count(), 0 );
}
#endif
}
// pointer constructor
@ -226,8 +222,6 @@ static void deleter_constructor()
// nullptr_deleter_constructor
#if !defined( BOOST_NO_CXX11_NULLPTR )
void deleter3( boost::detail::sp_nullptr_t )
{
++m;
@ -260,14 +254,6 @@ static void nullptr_deleter_constructor()
deleter3_test_<void const volatile>();
}
#else
static void nullptr_deleter_constructor()
{
}
#endif
// allocator constructor
template<class T> static void allocator_test_()
@ -300,8 +286,6 @@ static void allocator_constructor()
// nullptr_allocator_constructor
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> static void allocator3_test_()
{
{
@ -329,14 +313,6 @@ static void nullptr_allocator_constructor()
allocator3_test_<void const volatile>();
}
#else
static void nullptr_allocator_constructor()
{
}
#endif
// copy constructor
template<class T> static void empty_copy_test()
@ -1253,8 +1229,6 @@ static void move_assignment()
// nullptr assignment
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> static void test_nullptr_assign( boost::local_shared_ptr<T> p1 )
{
p1 = nullptr;
@ -1307,14 +1281,6 @@ static void nullptr_assignment()
BOOST_TEST( X::instances == 0 );
}
#else
static void nullptr_assignment()
{
}
#endif
// default_reset
template<class T> static void test_default_reset( boost::local_shared_ptr<T> p1 )

View File

@ -13,8 +13,6 @@
#include <cstddef>
#include <memory>
#if !defined( BOOST_NO_CXX11_NULLPTR )
struct X
{
static int instances;
@ -101,12 +99,3 @@ int main()
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@ -52,17 +52,13 @@ static Z z;
static boost::shared_ptr<X> p1;
static boost::weak_ptr<X> p2;
#if !defined( BOOST_NO_CXX11_NULLPTR )
static boost::shared_ptr<X> p3( nullptr );
#endif
Z::Z()
{
p1.reset( new X );
p2 = p1;
#if !defined( BOOST_NO_CXX11_NULLPTR )
p3.reset( new X );
#endif
}
int main()
@ -73,13 +69,9 @@ int main()
BOOST_TEST_EQ( p2.use_count(), 1 );
BOOST_TEST_EQ( p2.lock(), p1 );
#if !defined( BOOST_NO_CXX11_NULLPTR )
BOOST_TEST( p3.get() != 0 );
BOOST_TEST_EQ( p3.use_count(), 1 );
#endif
return boost::report_errors();
}

View File

@ -125,8 +125,6 @@ int main()
BOOST_TEST( Y::instances == 0 );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
{
boost::shared_ptr<Y> p( nullptr, YD() );
@ -145,8 +143,6 @@ int main()
BOOST_TEST( del.moved_ );
}
#endif
return boost::report_errors();
}

View File

@ -14,8 +14,6 @@
#include <cstddef>
#include <memory>
#if !defined( BOOST_NO_CXX11_NULLPTR )
struct X
{
static int instances;
@ -130,12 +128,3 @@ int main()
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif