153#include <type_traits>
155VTK_ABI_NAMESPACE_BEGIN
169 template <
typename U>
171 template <
typename U>
173 template <
typename U>
180 template <
typename U = T>
181 static void CheckTypes() noexcept
184 "vtkNew<T>'s T type has not been defined. Missing include?");
186 "Cannot store an object with undefined type in "
187 "vtkNew. Missing include?");
188 static_assert(std::is_base_of<T, U>::value,
189 "Argument type is not compatible with vtkNew<T>'s "
191 static_assert(std::is_base_of<vtkObjectBase, T>::value,
192 "vtkNew can only be used with subclasses of vtkObjectBase.");
202 vtkNew::CheckTypes();
216 template <
typename U>
220 vtkNew::CheckTypes<U>();
234 T* obj = this->Object;
237 this->Object =
nullptr;
257 T*
Get() const noexcept {
return this->Object; }
258 operator T*()
const noexcept {
return static_cast<T*
>(this->Object); }
266 T&
operator*() const noexcept {
return *
static_cast<T*
>(this->Object); }
274 this->Object = other.Object;
275 other.Object =
nullptr;
282 friend void vtkGarbageCollectorReport<T>(
Detect and break reference loops.
Allocate and hold a VTK object.
void Reset()
Deletes reference to instance of T.
T * Get() const noexcept
Get a raw pointer to the contained object.
vtkNew()
Create a new T on construction.
T * operator->() const noexcept
Enable pointer-like dereference syntax.
vtkNew(vtkNew &&o) noexcept
Move the object into the constructed vtkNew wrapper, stealing its reference.
~vtkNew()
Deletes reference to instance of T.
vtkNew(vtkNew< U > &&o) noexcept
Move the object into the constructed vtkNew wrapper, stealing its reference.
T * GetPointer() const noexcept
Get a raw pointer to the contained object.
T & operator*() const noexcept
Dereference the pointer and return a reference to the contained object.
vtkNew< T > & operator=(vtkNew< T > &&other) noexcept
Move assignment operator.
abstract base class for most VTK objects
Hold a reference to a vtkObjectBase instance.
a weak reference to a vtkObject.
void vtkGarbageCollectorReport(vtkGarbageCollector *collector, vtkNew< T > &ptr, const char *desc)
Function to report a reference held by a vtkNew to a collector.