126#ifndef vtkSmartPointer_h
127#define vtkSmartPointer_h
135#include <type_traits>
138VTK_ABI_NAMESPACE_BEGIN
146 template <
typename U = T>
147 static void CheckTypes()
noexcept
150 "vtkSmartPointer<T>'s T type has not been defined. Missing "
153 "Cannot store an object with undefined type in "
154 "vtkSmartPointer. Missing include?");
155 static_assert(std::is_base_of<T, U>::value,
156 "Argument type is not compatible with vtkSmartPointer<T>'s "
158 static_assert(std::is_base_of<vtkObjectBase, T>::value,
159 "vtkSmartPointer can only be used with subclasses of "
187 vtkSmartPointer::CheckTypes<U>();
205 vtkSmartPointer::CheckTypes<U>();
216 vtkSmartPointer::CheckTypes();
219 template <
typename U>
223 vtkSmartPointer::CheckTypes<U>();
231 template <
typename U>
235 vtkSmartPointer::CheckTypes<U>();
256 vtkSmartPointer::CheckTypes<U>();
267 template <
typename U>
270 vtkSmartPointer::CheckTypes<U>();
280 template <
typename U>
283 vtkSmartPointer::CheckTypes<U>();
294 T*
Get() const noexcept {
return static_cast<T*
>(this->
Object); }
300 operator T*()
const noexcept {
return static_cast<T*
>(this->
Object); }
332 template <
class... ArgsT>
377#if defined(__HP_aCC) || defined(__IBMCPP__)
378#define VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(op) \
379 bool operator op(NullPointerOnly*) const { return ::operator op(*this, 0); }
382 class NullPointerOnly
387 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(==)
388 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(!=)
389 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<)
390 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(<=)
391 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>)
392 VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND(>=)
393#undef VTK_SMART_POINTER_DEFINE_OPERATOR_WORKAROUND
420VTK_ABI_NAMESPACE_BEGIN
421#define VTK_SMART_POINTER_DEFINE_OPERATOR(op) \
422 template <class T, class U> \
423 inline bool operator op(const vtkSmartPointer<T>& l, const vtkSmartPointer<U>& r) \
425 return (l.GetPointer() op r.GetPointer()); \
427 template <class T, class U> \
428 inline bool operator op(T* l, const vtkSmartPointer<U>& r) \
430 return (l op r.GetPointer()); \
432 template <class T, class U> \
433 inline bool operator op(const vtkSmartPointer<T>& l, U* r) \
435 return (l.GetPointer() op r); \
437 template <class T, class U> \
438 inline bool operator op(const vtkNew<T>& l, const vtkSmartPointer<U>& r) \
440 return (l.GetPointer() op r.GetPointer()); \
442 template <class T, class U> \
443 inline bool operator op(const vtkSmartPointer<T>& l, const vtkNew<U>& r) \
445 return (l.GetPointer() op r.GetPointer); \
458#undef VTK_SMART_POINTER_DEFINE_OPERATOR
463VTK_ABI_NAMESPACE_BEGIN
484VTK_ABI_NAMESPACE_BEGIN
491 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.
std::size_t operator()(const vtkSmartPointer< T > &p) const
ostream & operator<<(ostream &os, const vtkSmartPointer< T > &p)
Streaming operator to print smart pointer like regular pointers.
#define VTK_SMART_POINTER_DEFINE_OPERATOR(op)