# vtkNew and vtkSmartPointer

**URL:** https://discourse.vtk.org/t/vtknew-and-vtksmartpointer/469
**Category:** Development
**Created:** [March 13, 2019, 1:35am UTC](https://discourse.vtk.org/t/vtknew-and-vtksmartpointer/469 "2019-03-13T01:35:54Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![allison.vacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allison.vacanti/32/679_2.png) [@allison.vacanti](https://discourse.vtk.org/u/allison.vacanti)
#### Post date: [March 19, 2019, 7:13pm UTC](https://discourse.vtk.org/t/vtknew-and-vtksmartpointer/469/20 "2019-03-19T19:13:13Z")

</div>

The current implementation of `vtkNew` and `vtkSmartPointer` is already complete. By “making everything consistent / uniform”, do you mean making smart pointers replace raw pointers everywhere? If so, I’ve started another discussion to go over the specific issue of using smart pointers in VTK’s API:

> [@vtkSmartPointer and vtkNew in VTK's API. Best practices?](https://discourse.vtk.org/t/vtksmartpointer-and-vtknew-in-vtks-api-best-practices/518):
>
> As best practices emerge in a post-C++11 world, one of the newer guidelines becoming commonplace is “don’t use raw pointers.” Preferring smart pointers prevents a host of mistakes and provides an additional level of safety and robustness over explicit memory (or refcount) management. Obviously this doesn’t fit much of VTK’s historical usage, but there are a few ways we can help make it easier to use VTK from projects with more modern coding practices. The vtkNew, vtkSmartPointer, and vtkWeakPoi…

In a perfect world, it’d be good to start using smart pointers in our APIs. But realistically, I don’t see that happening as it would break virtual APIs and/or introduce hidden overload issues for projects that extend VTK’s classes. If we wanted to do that, we might as well rewrite VTK from the ground up and use internal `shared_ptr`s to manage object lifetimes, like VTK-m does.

With that effort vs. benefit ratio, I more or less expect the end result to be “leave things as they are”, but wanted to start the discussion, gauge interest, and see what possible solutions the community comes up with.

---

_[View the full topic](https://discourse.vtk.org/t/vtknew-and-vtksmartpointer/469)._
