52 #ifndef __PCL_AutoPointer_h
53 #define __PCL_AutoPointer_h
58 #include <pcl/Diagnostics.h>
62 #ifdef __PCL_QT_INTERFACE
63 # include <QtCore/QObject>
64 # include <QtGui/QAction>
120 PCL_PRECONDITION( p !=
nullptr )
244 template <
class T,
class D = StandardDeleter<T>>
289 , m_autoDelete( autoDelete )
312 , m_autoDelete( autoDelete )
332 : m_deleter( x.m_deleter )
333 , m_autoDelete( x.m_autoDelete )
342 : m_deleter( std::move( x.m_deleter ) )
343 , m_autoDelete( x.m_autoDelete )
345 m_pointer = x.Release();
369 if ( m_pointer != p )
372 if ( m_pointer !=
nullptr )
373 m_deleter( Release() );
389 if ( m_pointer !=
nullptr )
460 return m_pointer ==
nullptr;
501 m_autoDelete = enable;
512 EnableAutoDelete( !disable );
554 m_deleter = x.m_deleter;
555 m_autoDelete = x.m_autoDelete;
565 SetPointer( x.Release() );
566 m_deleter = std::move( x.m_deleter );
567 m_autoDelete = x.m_autoDelete;
620 PCL_PRECONDITION( m_pointer !=
nullptr )
630 PCL_PRECONDITION( m_pointer !=
nullptr )
640 PCL_PRECONDITION( m_pointer !=
nullptr )
650 PCL_PRECONDITION( m_pointer !=
nullptr )
658 operator bool()
const
670 bool b = x1.m_autoDelete; x1.m_autoDelete = x2.m_autoDelete; x2.m_autoDelete = b;
675 pointer m_pointer =
nullptr;
677 bool m_autoDelete =
true;
682 #ifdef __PCL_QT_INTERFACE
695 class PCL_CLASS QObjectDeferredDeleter
702 using value_type = Q;
713 void operator()( pointer p )
const
715 PCL_PRECONDITION( p !=
nullptr )
729 using AutoQObjectPointer = AutoPointer<Q, QObjectDeferredDeleter<Q>>;
731 using AutoQActionPointer = AutoQObjectPointer<QAction>;
737 #define ASSERT_COPIABLE_T() \
738 static_assert( std::is_copy_constructible<T>::value, "AutoPointerCloner<> requires a copy-constructible type." )
754 template <
class T,
class D = StandardDeleter<T> >
844 this->m_pointer = x ?
new value_type( *x ) :
nullptr;
845 this->m_deleter = x.m_deleter;
846 this->m_autoDelete = x || x.m_autoDelete;
865 this->m_pointer = x ?
new value_type( *x ) :
nullptr;
866 this->m_deleter = x.m_deleter;
867 this->m_autoDelete = x || x.m_autoDelete;
901 this->SetPointer( x ?
new value_type( *x ) :
nullptr );
902 this->m_deleter = x.m_deleter;
903 this->m_autoDelete = x || x.m_autoDelete;
930 this->SetPointer( x ?
new value_type( *x ) :
nullptr );
931 this->m_deleter = x.m_deleter;
932 this->m_autoDelete = x || x.m_autoDelete;
942 (void)base_type::operator =( std::move( x ) );
957 this->SetPointer( p );
962 #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