29#ifndef vtkSmartPointer_h
30#define vtkSmartPointer_h
47 template <
typename U = T>
48 static void CheckTypes()
noexcept
51 "vtkSmartPointer<T>'s T type has not been defined. Missing "
54 "Cannot store an object with undefined type in "
55 "vtkSmartPointer. Missing include?");
56 static_assert(std::is_base_of<T, U>::value,
57 "Argument type is not compatible with vtkSmartPointer<T>'s "
59 static_assert(std::is_base_of<vtkObjectBase, T>::value,
60 "vtkSmartPointer can only be used with subclasses of "
88 vtkSmartPointer::CheckTypes<U>();
106 vtkSmartPointer::CheckTypes<U>();
117 vtkSmartPointer::CheckTypes();
120 template <
typename U>
124 vtkSmartPointer::CheckTypes<U>();
132 template <
typename U>
136 vtkSmartPointer::CheckTypes<U>();
157 vtkSmartPointer::CheckTypes<U>();
168 template <
typename U>
171 vtkSmartPointer::CheckTypes<U>();
181 template <
typename U>
184 vtkSmartPointer::CheckTypes<U>();
195 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
201 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
270#if defined(__HP_aCC) || defined(__IBMCPP__)
271#define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
272 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
275 class NullPointerOnly
280 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
281 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
282 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
283 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
284 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
285 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
286#undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND
301#define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \
302 template <class T, class U> \
303 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \
305 return (l.GetPointer() op r.GetPointer()); \
307 template <class T, class U> \
308 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \
310 return (l op r.GetPointer()); \
312 template <class T, class U> \
313 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \
315 return (l.GetPointer() op r); \
317 template <class T, class U> \
318 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \
320 return (l.GetPointer() op r.GetPointer()); \
322 template <class T, class U> \
323 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \
325 return (l.GetPointer() op r.GetPointer); \
338#undef VTK_SMART_POINTER_DEFINE_OPERATOR
367 return os << static_cast<const vtkSmartPointerBase&>(p);
Allocate and hold a VTK object.
Non-templated superclass for vtkSmartPointer.
vtkSmartPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
vtkSmartPointerBase() noexcept
Initialize smart pointer to nullptr.
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > NewInstance(T *t)
Create a new instance of the given VTK object.
vtkSmartPointer() noexcept
Initialize smart pointer to nullptr.
vtkSmartPointer(vtkNew< U > &&r) noexcept
Move the pointer from the vtkNew smart pointer to the new vtkSmartPointer, stealing its reference and...
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 & operator=(U *r)
Assign object to reference.
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 &r)
Assign object to reference.
vtkSmartPointer & operator=(const vtkNew< U > &r)
Assign object to reference.
T * operator->() const noexcept
Provides normal pointer target member access using operator ->.
vtkSmartPointer(vtkSmartPointer< U > &&r) noexcept
Initialize smart pointer with a new reference to the same object referenced by given smart pointer.
static vtkSmartPointer< T > Take(T *t)
Transfer ownership of one reference to the given VTK object to a new smart pointer.
T * GetPointer() const noexcept
Get the contained pointer.
T & operator*() const noexcept
Dereference the pointer and return a reference to the contained object.
vtkSmartPointer & operator=(const vtkSmartPointer< U > &r)
Assign object to reference.
static vtkSmartPointer< T > ExtendedNew()
Create an instance of a VTK object in a memkind extended memory space.
vtkSmartPointer(T *r, const NoReference &n)
T * Get() const noexcept
Get the contained pointer.
vtkSmartPointer(const vtkNew< U > &r)
Initialize smart pointer to given object.
static vtkSmartPointer< T > New()
Create an instance of a VTK 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.
ostream & operator<<(ostream &os, const vtkSmartPointer< T > &p)
Streaming operator to print smart pointer like regular pointers.
#define VTK_SMART_POINTER_DEFINE_OPERATOR(op)