138 #ifndef vtkSmartPointer_h
139 #define vtkSmartPointer_h
146 #include <type_traits>
156 template <
typename U = T>
157 static void CheckTypes() noexcept
160 "vtkSmartPointer<T>'s T type has not been defined. Missing "
163 "Cannot store an object with undefined type in "
164 "vtkSmartPointer. Missing include?");
166 "Argument type is not compatible with vtkSmartPointer<T>'s "
169 "vtkSmartPointer can only be used with subclasses of "
197 vtkSmartPointer::CheckTypes<U>();
215 vtkSmartPointer::CheckTypes<U>();
226 vtkSmartPointer::CheckTypes();
229 template <
typename U>
233 vtkSmartPointer::CheckTypes<U>();
241 template <
typename U>
245 vtkSmartPointer::CheckTypes<U>();
266 vtkSmartPointer::CheckTypes<U>();
277 template <
typename U>
280 vtkSmartPointer::CheckTypes<U>();
290 template <
typename U>
293 vtkSmartPointer::CheckTypes<U>();
304 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
310 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
379 #if defined(__HP_aCC) || defined(__IBMCPP__)
380 #define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
381 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
384 class NullPointerOnly
389 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
390 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
391 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
392 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
393 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
394 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
395 #undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND
410 #define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \
411 template <class T, class U> \
412 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \
414 return (l.GetPointer() op r.GetPointer()); \
416 template <class T, class U> \
417 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \
419 return (l op r.GetPointer()); \
421 template <class T, class U> \
422 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \
424 return (l.GetPointer() op r); \
426 template <class T, class U> \
427 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \
429 return (l.GetPointer() op r.GetPointer()); \
431 template <class T, class U> \
432 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \
434 return (l.GetPointer() op r.GetPointer); \
447 #undef VTK_SMART_POINTER_DEFINE_OPERATOR
454 template <
typename T>
462 template <
typename T>
476 return os << static_cast<const vtkSmartPointerBase&>(p);
Allocate and hold a VTK object.
Non-templated superclass for vtkSmartPointer.
vtkSmartPointerBase() noexcept
Initialize smart pointer to nullptr.
vtkSmartPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
Hold a reference to a vtkObjectBase instance.
vtkSmartPointer() noexcept
Initialize smart pointer to nullptr.
T * Get() const noexcept
Get the contained pointer.
vtkSmartPointer(vtkNew< U > &&r) noexcept
Move the pointer from the vtkNew smart pointer to the new vtkSmartPointer, stealing its reference and...
static vtkSmartPointer< T > NewInstance(T *t)
Create a new instance of the given VTK object.
vtkSmartPointer(const vtkSmartPointer &r)
Initialize smart pointer with a new reference to the same object referenced by given smart pointer.
vtkSmartPointer(T *r)
Initialize smart pointer to given object.
vtkSmartPointer(const vtkSmartPointer< U > &r)
Initialize smart pointer with a new reference to the same object referenced by given smart pointer.
void TakeReference(T *t)
Transfer ownership of one reference to the given VTK object to this smart pointer.
vtkSmartPointer(vtkSmartPointer &&r) noexcept
Move the contents of r into this.
vtkSmartPointer & operator=(const vtkSmartPointer< U > &r)
Assign object to reference.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
vtkSmartPointer(vtkSmartPointer< U > &&r) noexcept
Initialize smart pointer with a new reference to the same object referenced by given smart pointer.
vtkSmartPointer & operator=(const vtkNew< U > &r)
Assign object to reference.
vtkSmartPointer & operator=(U *r)
Assign object to reference.
T & operator*() const noexcept
Dereference the pointer and return a reference to the contained object.
T * GetPointer() const noexcept
Get the contained pointer.
T * operator->() const noexcept
Provides normal pointer target member access using operator ->.
static vtkSmartPointer< T > ExtendedNew()
Create an instance of a VTK object in a memkind extended memory space.
vtkSmartPointer(T *r, const NoReference &n)
vtkSmartPointer & operator=(const vtkSmartPointer &r)
Assign object to reference.
static vtkSmartPointer< T > Take(T *t)
Transfer ownership of one reference to the given VTK object to a new smart pointer.
vtkSmartPointer(const vtkNew< U > &r)
Initialize smart pointer to given object.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
vtkSmartPointer< T > MakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
#define VTK_SMART_POINTER_DEFINE_OPERATOR(op)
ostream & operator<<(ostream &os, const vtkSmartPointer< T > &p)
Streaming operator to print smart pointer like regular pointers.