17#ifndef vtkSmartPointer_h
18#define vtkSmartPointer_h
29VTK_ABI_NAMESPACE_BEGIN
37 template <
typename U = T>
38 static void CheckTypes()
noexcept
41 "vtkSmartPointer<T>'s T type has not been defined. Missing "
44 "Cannot store an object with undefined type in "
45 "vtkSmartPointer. Missing include?");
46 static_assert(std::is_base_of<T, U>::value,
47 "Argument type is not compatible with vtkSmartPointer<T>'s "
49 static_assert(std::is_base_of<vtkObjectBase, T>::value,
50 "vtkSmartPointer can only be used with subclasses of "
78 vtkSmartPointer::CheckTypes<U>();
96 vtkSmartPointer::CheckTypes<U>();
107 vtkSmartPointer::CheckTypes();
110 template <
typename U>
114 vtkSmartPointer::CheckTypes<U>();
122 template <
typename U>
126 vtkSmartPointer::CheckTypes<U>();
147 vtkSmartPointer::CheckTypes<U>();
158 template <
typename U>
161 vtkSmartPointer::CheckTypes<U>();
171 template <
typename U>
174 vtkSmartPointer::CheckTypes<U>();
185 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
191 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
223 template <
class... ArgsT>
268#if defined(__HP_aCC) || defined(__IBMCPP__)
269#define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
270 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
273 class NullPointerOnly
278 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
279 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
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#undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND
307 std::hash<T*> Hasher;
311VTK_ABI_NAMESPACE_BEGIN
312#define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \
313 template <class T, class U> \
314 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \
316 return (l.GetPointer() op r.GetPointer()); \
318 template <class T, class U> \
319 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \
321 return (l op r.GetPointer()); \
323 template <class T, class U> \
324 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \
326 return (l.GetPointer() op r); \
328 template <class T, class U> \
329 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \
331 return (l.GetPointer() op r.GetPointer()); \
333 template <class T, class U> \
334 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \
336 return (l.GetPointer() op r.GetPointer); \
349#undef VTK_SMART_POINTER_DEFINE_OPERATOR
354VTK_ABI_NAMESPACE_BEGIN
375VTK_ABI_NAMESPACE_BEGIN
382 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.
static vtkSmartPointer< T > New(ArgsT &&... args)
Create an instance of a VTK object.
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)