23 #ifndef vtkSmartPointer_h
24 #define vtkSmartPointer_h
31 #include <type_traits>
41 template <
typename U = T>
42 static void CheckTypes() noexcept
45 "vtkSmartPointer<T>'s T type has not been defined. Missing "
48 "Cannot store an object with undefined type in "
49 "vtkSmartPointer. Missing include?");
51 "Argument type is not compatible with vtkSmartPointer<T>'s "
54 "vtkSmartPointer can only be used with subclasses of "
82 vtkSmartPointer::CheckTypes<U>();
100 vtkSmartPointer::CheckTypes<U>();
111 vtkSmartPointer::CheckTypes();
114 template <
typename U>
118 vtkSmartPointer::CheckTypes<U>();
126 template <
typename U>
130 vtkSmartPointer::CheckTypes<U>();
151 vtkSmartPointer::CheckTypes<U>();
162 template <
typename U>
165 vtkSmartPointer::CheckTypes<U>();
175 template <
typename U>
178 vtkSmartPointer::CheckTypes<U>();
189 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
195 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
264 #if defined(__HP_aCC) || defined(__IBMCPP__)
265 #define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
266 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
269 class NullPointerOnly
274 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
275 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
276 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
277 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
278 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
279 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
280 #undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND
295 #define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \
296 template <class T, class U> \
297 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \
299 return (l.GetPointer() op r.GetPointer()); \
301 template <class T, class U> \
302 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \
304 return (l op r.GetPointer()); \
306 template <class T, class U> \
307 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \
309 return (l.GetPointer() op r); \
311 template <class T, class U> \
312 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \
314 return (l.GetPointer() op r.GetPointer()); \
316 template <class T, class U> \
317 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \
319 return (l.GetPointer() op r.GetPointer); \
332 #undef VTK_SMART_POINTER_DEFINE_OPERATOR
339 template <
typename T>
347 template <
typename T>
361 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.