43#ifndef vtkWeakPointer_h
44#define vtkWeakPointer_h
61 template <
typename U = T>
62 static void CheckTypes()
noexcept
65 "vtkWeakPointer<T>'s T type has not been defined. Missing "
68 "Cannot store an object with undefined type in "
69 "vtkWeakPointer. Missing include?");
70 static_assert(std::is_base_of<T, U>::value,
71 "Argument type is not compatible with vtkWeakPointer<T>'s "
73 static_assert(std::is_base_of<vtkObjectBase, T>::value,
74 "vtkWeakPointer can only be used with subclasses of "
100 vtkWeakPointer::CheckTypes<U>();
117 vtkWeakPointer::CheckTypes<U>();
128 vtkWeakPointer::CheckTypes();
131 template <
typename U>
135 vtkWeakPointer::CheckTypes<U>();
152 vtkWeakPointer::CheckTypes<U>();
172 vtkWeakPointer::CheckTypes<U>();
185 vtkWeakPointer::CheckTypes();
190 template <
typename U>
193 vtkWeakPointer::CheckTypes<U>();
205 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
206 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
224#if defined(__HP_aCC) || defined(__IBMCPP__)
225#define VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
226 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
229 class NullPointerOnly
234 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
235 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
236 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
237 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
238 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
239 VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
240#undef VTK_WEAK_POINTER_DEFINE_OPERATOR_WORKAROUND
255#define VTK_WEAK_POINTER_DEFINE_OPERATOR(op) \
256 template <class T, class U> \
257 inline bool operator op(const vtkWeakPointer<T>& l, const vtkWeakPointer<U>& r) \
259 return (l.GetPointer() op r.GetPointer()); \
261 template <class T, class U> \
262 inline bool operator op(T* l, const vtkWeakPointer<U>& r) \
264 return (l op r.GetPointer()); \
266 template <class T, class U> \
267 inline bool operator op(const vtkWeakPointer<T>& l, U* r) \
269 return (l.GetPointer() op r); \
271 template <class T, class U> \
272 inline bool operator op(const vtkNew<T>& l, const vtkWeakPointer<U>& r) \
274 return (l.GetPointer() op r.GetPointer()); \
276 template <class T, class U> \
277 inline bool operator op(const vtkWeakPointer<T>& l, const vtkNew<U>& r) \
279 return (l.GetPointer() op r.GetPointer); \
292#undef VTK_WEAK_POINTER_DEFINE_OPERATOR
313 return os << static_cast<const vtkWeakPointerBase&>(p);
Allocate and hold a VTK object.
Non-templated superclass for vtkWeakPointer.
vtkWeakPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
vtkWeakPointerBase() noexcept
Initialize smart pointer to nullptr.
a weak reference to a vtkObject.
T * GetPointer() const noexcept
Get the contained pointer.
vtkWeakPointer & operator=(vtkWeakPointer< U > &&r) noexcept
Move r's object into this weak pointer, setting r to nullptr.
vtkWeakPointer & operator=(const vtkNew< U > &r)
Assign object to reference.
vtkWeakPointer(const vtkWeakPointer< U > &r)
Initialize smart pointer with the given smart pointer.
vtkWeakPointer() noexcept
Initialize smart pointer to nullptr.
vtkWeakPointer(vtkWeakPointer< U > &&r) noexcept
Initialize smart pointer with the given smart pointer.
vtkWeakPointer(vtkWeakPointer &&r) noexcept
Move r's object into the new weak pointer, setting r to nullptr.
vtkWeakPointer & operator=(const vtkWeakPointer &r)
Assign object to reference.
vtkWeakPointer & operator=(vtkWeakPointer &&r) noexcept
Move r's object into this weak pointer, setting r to nullptr.
T & operator*() const noexcept
Dereference the pointer and return a reference to the contained object.
vtkWeakPointer & operator=(const vtkWeakPointer< U > &r)
Assign object to reference.
vtkWeakPointer(T *r, const NoReference &n)
Get the contained pointer.
vtkWeakPointer & operator=(T *r)
Assign object to reference.
vtkWeakPointer(const vtkWeakPointer &r)
Initialize smart pointer with the given smart pointer.
T * Get() const noexcept
Get the contained pointer.
vtkWeakPointer(T *r)
Initialize smart pointer to given object.
T * operator->() const noexcept
Provides normal pointer target member access using operator ->.
vtkWeakPointer(const vtkNew< U > &r)
Initialize smart pointer with the given smart pointer.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkWeakPointer< T > TakeWeakPointer(T *obj)
Construct a vtkWeakPointer<T> containing obj.
ostream & operator<<(ostream &os, const vtkWeakPointer< T > &p)
Streaming operator to print smart pointer like regular pointers.
#define VTK_WEAK_POINTER_DEFINE_OPERATOR(op)