Skip to content

Commit

Permalink
Remove uses of BOOST_SP_NOEXCEPT from weak_ptr.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Oct 2, 2024
1 parent 3834c02 commit ff41b5c
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions include/boost/smart_ptr/weak_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <memory>
#include <cstddef>

Expand All @@ -33,18 +32,18 @@ template<class T> class weak_ptr

typedef typename boost::detail::sp_element< T >::type element_type;

BOOST_CONSTEXPR weak_ptr() BOOST_SP_NOEXCEPT : px(0), pn()
BOOST_CONSTEXPR weak_ptr() noexcept : px(0), pn()
{
}

// generated copy constructor, assignment, destructor are fine...
// ... except in C++0x, move disables the implicit copy

weak_ptr( weak_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
weak_ptr( weak_ptr const & r ) noexcept : px( r.px ), pn( r.pn )
{
}

weak_ptr & operator=( weak_ptr const & r ) BOOST_SP_NOEXCEPT
weak_ptr & operator=( weak_ptr const & r ) noexcept
{
px = r.px;
pn = r.pn;
Expand All @@ -70,28 +69,28 @@ template<class T> class weak_ptr

template<class Y>
weak_ptr( weak_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
BOOST_SP_NOEXCEPT : px(r.lock().get()), pn(r.pn)
noexcept : px(r.lock().get()), pn(r.pn)
{
boost::detail::sp_assert_convertible< Y, T >();
}

template<class Y>
weak_ptr( weak_ptr<Y> && r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
BOOST_SP_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
noexcept : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
{
boost::detail::sp_assert_convertible< Y, T >();
r.px = 0;
}

// for better efficiency in the T == Y case
weak_ptr( weak_ptr && r )
BOOST_SP_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
noexcept : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
{
r.px = 0;
}

// for better efficiency in the T == Y case
weak_ptr & operator=( weak_ptr && r ) BOOST_SP_NOEXCEPT
weak_ptr & operator=( weak_ptr && r ) noexcept
{
this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
return *this;
Expand All @@ -100,26 +99,26 @@ template<class T> class weak_ptr

template<class Y>
weak_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
noexcept : px( r.px ), pn( r.pn )
{
boost::detail::sp_assert_convertible< Y, T >();
}

// aliasing
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) noexcept: px( p ), pn( r.pn )
{
}

template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) noexcept: px( p ), pn( r.pn )
{
}

template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( std::move( r.pn ) )
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) noexcept: px( p ), pn( std::move( r.pn ) )
{
}

template<class Y>
weak_ptr & operator=( weak_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
weak_ptr & operator=( weak_ptr<Y> const & r ) noexcept
{
boost::detail::sp_assert_convertible< Y, T >();

Expand All @@ -130,14 +129,14 @@ template<class T> class weak_ptr
}

template<class Y>
weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_SP_NOEXCEPT
weak_ptr & operator=( weak_ptr<Y> && r ) noexcept
{
this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
return *this;
}

template<class Y>
weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
weak_ptr & operator=( shared_ptr<Y> const & r ) noexcept
{
boost::detail::sp_assert_convertible< Y, T >();

Expand All @@ -147,63 +146,63 @@ template<class T> class weak_ptr
return *this;
}

shared_ptr<T> lock() const BOOST_SP_NOEXCEPT
shared_ptr<T> lock() const noexcept
{
return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() );
}

long use_count() const BOOST_SP_NOEXCEPT
long use_count() const noexcept
{
return pn.use_count();
}

bool expired() const BOOST_SP_NOEXCEPT
bool expired() const noexcept
{
return pn.use_count() == 0;
}

bool _empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
bool _empty() const noexcept // extension, not in std::weak_ptr
{
return pn.empty();
}

bool empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
bool empty() const noexcept // extension, not in std::weak_ptr
{
return pn.empty();
}

void reset() BOOST_SP_NOEXCEPT
void reset() noexcept
{
this_type().swap(*this);
}

void swap(this_type & other) BOOST_SP_NOEXCEPT
void swap(this_type & other) noexcept
{
std::swap(px, other.px);
pn.swap(other.pn);
}

template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const noexcept
{
return pn < rhs.pn;
}

template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const noexcept
{
return pn < rhs.pn;
}

template<class Y> bool owner_equals( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
template<class Y> bool owner_equals( weak_ptr<Y> const & rhs ) const noexcept
{
return pn == rhs.pn;
}

template<class Y> bool owner_equals( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
template<class Y> bool owner_equals( shared_ptr<Y> const & rhs ) const noexcept
{
return pn == rhs.pn;
}

std::size_t owner_hash_value() const BOOST_SP_NOEXCEPT
std::size_t owner_hash_value() const noexcept
{
return pn.hash_value();
}
Expand All @@ -218,12 +217,12 @@ template<class T> class weak_ptr

}; // weak_ptr

template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_SP_NOEXCEPT
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept
{
return a.owner_before( b );
}

template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_SP_NOEXCEPT
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) noexcept
{
a.swap(b);
}
Expand All @@ -236,7 +235,7 @@ template<class T> weak_ptr( shared_ptr<T> ) -> weak_ptr<T>;

// hash_value

template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) BOOST_SP_NOEXCEPT
template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) noexcept
{
return p.owner_hash_value();
}
Expand All @@ -250,15 +249,15 @@ namespace std

template<class T> struct hash< ::boost::weak_ptr<T> >
{
std::size_t operator()( ::boost::weak_ptr<T> const & p ) const BOOST_SP_NOEXCEPT
std::size_t operator()( ::boost::weak_ptr<T> const & p ) const noexcept
{
return p.owner_hash_value();
}
};

template<class T> struct equal_to< ::boost::weak_ptr<T> >
{
bool operator()( ::boost::weak_ptr<T> const & a, ::boost::weak_ptr<T> const & b ) const BOOST_SP_NOEXCEPT
bool operator()( ::boost::weak_ptr<T> const & a, ::boost::weak_ptr<T> const & b ) const noexcept
{
return a.owner_equals( b );
}
Expand Down

0 comments on commit ff41b5c

Please sign in to comment.