154#include <type_traits>
156VTK_ABI_NAMESPACE_BEGIN
170 template <
typename U>
172 template <
typename U>
174 template <
typename U>
181 template <
typename U = T>
182 static void CheckTypes() noexcept
185 "vtkNew<T>'s T type has not been defined. Missing include?");
187 "Cannot store an object with undefined type in "
188 "vtkNew. Missing include?");
189 static_assert(std::is_base_of<T, U>::value,
190 "Argument type is not compatible with vtkNew<T>'s "
192 static_assert(std::is_base_of<vtkObjectBase, T>::value,
193 "vtkNew can only be used with subclasses of vtkObjectBase.");
203 vtkNew::CheckTypes();
217 template <
typename U>
221 vtkNew::CheckTypes<U>();
235 T* obj = this->Object;
238 this->Object =
nullptr;
258 T*
Get() const noexcept {
return this->Object; }
259 operator T*()
const noexcept {
return static_cast<T*
>(this->Object); }
267 T&
operator*() const noexcept {
return *
static_cast<T*
>(this->Object); }
275 this->Object = other.Object;
276 other.Object =
nullptr;
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.
friend void vtkGarbageCollectorReport(vtkGarbageCollector *collector, vtkNew< T > &ptr, const char *desc)
Function to report a reference held by a vtkNew to a collector.
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.
friend class vtkWeakPointer
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.
friend class vtkSmartPointer
vtkNew< T > & operator=(vtkNew< T > &&other) noexcept
Move assignment operator.
abstract base class for most VTK objects
static constexpr bool value
void vtkGarbageCollectorReport(vtkGarbageCollector *collector, vtkNew< T > &ptr, const char *desc)
Function to report a reference held by a vtkNew to a collector.