forked from boostorg/smart_ptr
Add lsp_array_* tests
This commit is contained in:
@@ -57,6 +57,8 @@ public:
|
||||
|
||||
virtual void destroy() BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
virtual boost::shared_ptr<void> get_shared_ptr() const BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
void add_ref() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
#if defined( __has_builtin )
|
||||
@@ -114,6 +116,11 @@ public:
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual boost::shared_ptr<void> get_shared_ptr() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return const_pointer_cast<void>( pn_ );
|
||||
}
|
||||
};
|
||||
|
||||
class local_counted_impl_em: public local_counted_base
|
||||
@@ -126,6 +133,11 @@ public:
|
||||
{
|
||||
pn_.reset();
|
||||
}
|
||||
|
||||
virtual boost::shared_ptr<void> get_shared_ptr() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return const_pointer_cast<void>( pn_ );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -437,6 +437,36 @@ public:
|
||||
return pn? pn->local_use_count(): 0;
|
||||
}
|
||||
|
||||
// conversions to shared_ptr, weak_ptr
|
||||
|
||||
template<class Y> operator shared_ptr<Y>() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::sp_assert_convertible<T, Y>();
|
||||
|
||||
if( pn )
|
||||
{
|
||||
return static_pointer_cast<Y>( pn->get_shared_ptr() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return shared_ptr<Y>();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Y> operator weak_ptr<Y>() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::sp_assert_convertible<T, Y>();
|
||||
|
||||
if( pn )
|
||||
{
|
||||
return static_pointer_cast<Y>( pn->get_shared_ptr() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return weak_ptr<Y>();
|
||||
}
|
||||
}
|
||||
|
||||
// swap
|
||||
|
||||
void swap( local_shared_ptr & r ) BOOST_SP_NOEXCEPT
|
||||
@@ -487,6 +517,31 @@ template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, local_sha
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator==( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.get() == b.get();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator!=( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.get() != b.get();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.owner_before( b );
|
||||
}
|
||||
|
||||
template<class T> inline void swap( local_shared_ptr<T> & a, local_shared_ptr<T> & b ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
a.swap( b );
|
||||
|
||||
Reference in New Issue
Block a user