Reference-counting helpers - Swap

This commit is contained in:
Emmanuel BENOîT 2019-01-02 16:51:18 +01:00
parent ddaa46867d
commit 8e2c773de1
2 changed files with 25 additions and 0 deletions

View file

@ -119,6 +119,11 @@ class T_RcPtr
template< typename Q , T_EnableForParent< Type , Q > = false >
T_Self& operator= ( T_RcPtr< Q >&& other );
// ---------------------------------------------------------------------
// Swapping
T_Self swap( T_Self& other ) noexcept;
// ---------------------------------------------------------------------
// Boolean conversion
@ -137,6 +142,9 @@ class T_RcPtr
Type& operator * ( ) const;
};
template< typename T >
void swap( T_RcPtr< T >& lhs , T_RcPtr< T >& rhs ) noexcept;
} // namespace
#endif // _H_EBCL_REFCOUNT

View file

@ -223,6 +223,23 @@ template<
/*----------------------------------------------------------------------------*/
template< typename T >
inline T_RcPtr< T > T_RcPtr< T >::swap(
T_RcPtr< T >& other ) noexcept
{
std::swap( target_ , other.target_ );
return *this;
}
template< typename T >
inline void swap( T_RcPtr< T >& lhs ,
T_RcPtr< T >& rhs ) noexcept
{
lhs.swap( rhs );
}
/*----------------------------------------------------------------------------*/
template< typename T >
inline T_RcPtr< T >::operator bool ( ) const noexcept
{