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 " 79 vtkSmartPointer::CheckTypes<U>();
93 vtkSmartPointer::CheckTypes<U>();
104 vtkSmartPointer::CheckTypes();
107 template <
typename U>
111 vtkSmartPointer::CheckTypes<U>();
119 template <
typename U>
123 vtkSmartPointer::CheckTypes<U>();
144 vtkSmartPointer::CheckTypes<U>();
155 template <
typename U>
158 vtkSmartPointer::CheckTypes<U>();
168 template <
typename U>
171 vtkSmartPointer::CheckTypes<U>();
182 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
188 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
248 #if defined(__HP_aCC) || defined(__IBMCPP__) 249 #define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \ 250 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); } 253 class NullPointerOnly
258 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
259 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
260 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
261 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
262 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
263 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
264 #undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND 279 #define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \ 280 template <class T, class U> \ 281 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \ 283 return (l.GetPointer() op r.GetPointer()); \ 285 template <class T, class U> \ 286 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \ 288 return (l op r.GetPointer()); \ 290 template <class T, class U> \ 291 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \ 293 return (l.GetPointer() op r); \ 295 template <class T, class U> \ 296 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \ 298 return (l.GetPointer() op r.GetPointer()); \ 300 template <class T, class U> \ 301 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \ 303 return (l.GetPointer() op r.GetPointer); \ 316 #undef VTK_SMART_POINTER_DEFINE_OPERATOR 323 template <
typename T>
331 template <
typename T>
343 inline ostream& operator<<(ostream& os, const vtkSmartPointer<T>& p)
345 return os << static_cast<const vtkSmartPointerBase&>(p);
vtkSmartPointerBase() noexcept
Initialize smart pointer to nullptr.
T & operator*() const noexcept
Dereference the pointer and return a reference to the contained object.
static vtkSmartPointer< T > Take(T *t)
Transfer ownership of one reference to the given VTK object to a new smart pointer.
T * Get() const noexcept
Get the contained pointer.
static vtkSmartPointer< T > NewInstance(T *t)
Create a new instance of the given VTK object.
vtkSmartPointer(const vtkNew< U > &r)
Initialize smart pointer to given object.
vtkSmartPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
vtkSmartPointer(T *r, const NoReference &n)
vtkSmartPointer(vtkSmartPointer< U > &&r) noexcept
Initialize smart pointer with a new reference to the same object referenced by given smart pointer...
Hold a reference to a vtkObjectBase instance.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkSmartPointer & operator=(U *r)
Assign object to reference.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
T * operator->() const noexcept
Provides normal pointer target member access using operator ->.
vtkSmartPointer(const vtkSmartPointer &r)
Initialize smart pointer with a new reference to the same object referenced by given smart pointer...
vtkSmartPointer & operator=(const vtkSmartPointer< U > &r)
Assign object to reference.
vtkSmartPointer(vtkNew< U > &&r) noexcept
Move the pointer from the vtkNew smart pointer to the new vtkSmartPointer, stealing its reference and...
vtkSmartPointer(vtkSmartPointer &&r) noexcept
Move the contents of r into this.
vtkSmartPointer(T *r)
Initialize smart pointer to given object.
vtkSmartPointer & operator=(const vtkNew< U > &r)
Assign object to reference.
Non-templated superclass for vtkSmartPointer.
vtkSmartPointer() noexcept
Initialize smart pointer to nullptr.
void TakeReference(T *t)
Transfer ownership of one reference to the given VTK object to this smart pointer.
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
vtkSmartPointer & operator=(const vtkSmartPointer &r)
Assign object to reference.
Allocate and hold a VTK object.
T * GetPointer() const noexcept
Get the contained pointer.
vtkSmartPointer(const vtkSmartPointer< U > &r)
Initialize smart pointer with a new reference to the same object referenced by given smart pointer...
#define VTK_SMART_POINTER_DEFINE_OPERATOR(op)
vtkSmartPointer< T > MakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.