52 #ifndef __PCL_AutoPointer_h
53 #define __PCL_AutoPointer_h
58 #include <pcl/Diagnostics.h>
115 PCL_PRECONDITION( p !=
nullptr )
239 template <
class T,
class D = StandardDeleter<T> >
284 , m_autoDelete( autoDelete )
307 , m_autoDelete( autoDelete )
327 : m_deleter( x.m_deleter )
328 , m_autoDelete( x.m_autoDelete )
337 : m_deleter( std::move( x.m_deleter ) )
338 , m_autoDelete( x.m_autoDelete )
340 m_pointer = x.Release();
364 if ( m_pointer != p )
367 if ( m_pointer !=
nullptr )
368 m_deleter( Release() );
384 if ( m_pointer !=
nullptr )
455 return m_pointer ==
nullptr;
496 m_autoDelete = enable;
507 EnableAutoDelete( !disable );
549 m_deleter = x.m_deleter;
550 m_autoDelete = x.m_autoDelete;
560 SetPointer( x.Release() );
561 m_deleter = std::move( x.m_deleter );
562 m_autoDelete = x.m_autoDelete;
615 PCL_PRECONDITION( m_pointer !=
nullptr )
625 PCL_PRECONDITION( m_pointer !=
nullptr )
635 PCL_PRECONDITION( m_pointer !=
nullptr )
645 PCL_PRECONDITION( m_pointer !=
nullptr )
653 operator bool()
const
665 bool b = x1.m_autoDelete; x1.m_autoDelete = x2.m_autoDelete; x2.m_autoDelete = b;
670 pointer m_pointer =
nullptr;
672 bool m_autoDelete =
true;
677 #define ASSERT_COPIABLE_T() \
678 static_assert( std::is_copy_constructible<T>::value, "AutoPointerCloner<> requires a copy-constructible type." )
694 template <
class T,
class D = StandardDeleter<T> >
784 this->m_pointer = x ?
new value_type( *x ) :
nullptr;
785 this->m_deleter = x.m_deleter;
786 this->m_autoDelete = x || x.m_autoDelete;
805 this->m_pointer = x ?
new value_type( *x ) :
nullptr;
806 this->m_deleter = x.m_deleter;
807 this->m_autoDelete = x || x.m_autoDelete;
841 this->SetPointer( x ?
new value_type( *x ) :
nullptr );
842 this->m_deleter = x.m_deleter;
843 this->m_autoDelete = x || x.m_autoDelete;
870 this->SetPointer( x ?
new value_type( *x ) :
nullptr );
871 this->m_deleter = x.m_deleter;
872 this->m_autoDelete = x || x.m_autoDelete;
882 (void)base_type::operator =( std::move( x ) );
897 this->SetPointer( p );
902 #undef ASSERT_COPIABLE_T
A smart pointer able to generate dynamically allocated copies of the objects pointed to by other smar...
typename base_type::pointer pointer
AutoPointerCloner(pointer p, bool autoDelete=true, const deleter &d=deleter())
typename base_type::deleter deleter
typename base_type::value_type value_type
typename base_type::const_pointer const_pointer
AutoPointerCloner(bool autoDelete=true, const deleter &d=deleter())
AutoPointerCloner(const AutoPointerCloner &x)
AutoPointerCloner(const base_type &x)
AutoPointerCloner(base_type &&x)
A smart pointer with exclusive object ownership and optional automatic object destruction.
AutoPointer(bool autoDelete=true, const deleter &d=deleter())
const_pointer Ptr() const
void SetPointer(pointer p)
void DisableAutoDelete(bool disable=true)
friend void Swap(AutoPointer &x1, AutoPointer &x2)
AutoPointer(pointer p, bool autoDelete=true, const deleter &d=deleter())
const_pointer Pointer() const
AutoPointer(AutoPointer &&x)
const deleter & Deleter() const
AutoPointer(AutoPointer &x)
bool IsAutoDelete() const
void EnableAutoDelete(bool enable=true)
An object deleter that uses the standard delete operator.
void operator()(pointer p) const
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept