Reference-counting helpers - Swap
This commit is contained in:
parent
ddaa46867d
commit
8e2c773de1
2 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue