template<class T>
class vtkNew< T >
Allocate and hold a VTK object.
vtkNew is a class template that on construction allocates and initializes an instance of its template argument using T::New(). It assumes ownership of one reference during its lifetime, and calls T->Delete() on destruction.
Automatic casting is intentionally unavailable, calling GetPointer() will return a raw pointer. Users of this method should ensure that they do not return this pointer if the vtkNew will go out of scope without incrementing its reference count using vtkSmartPointer or similar.
a->SomeMethod();
b->SomeOtherMethod();
It should be noted that vtkNew is not a drop in replacement for vtkSmartPointer as it is not implicitly cast to a pointer in functions requiring a pointer. The GetPointer() method must be used, for example,
- See also
- vtkSmartPointer vtkWeakPointer
- Examples:
- vtkNew (Examples)
- Tests:
- vtkNew (Tests)
Definition at line 66 of file vtkNew.h.