# Page about vtkSmartPointer

**URL:** https://discourse.vtk.org/t/page-about-vtksmartpointer/4449
**Category:** Support
**Created:** [October 19, 2020, 9:48pm UTC](https://discourse.vtk.org/t/page-about-vtksmartpointer/4449 "2020-10-19T21:48:47Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![AllisonVacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allisonvacanti/32/2396_2.png) [@AllisonVacanti](https://discourse.vtk.org/u/AllisonVacanti)
#### Post date: [October 27, 2020, 2:21pm UTC](https://discourse.vtk.org/t/page-about-vtksmartpointer/4449/13 "2020-10-27T14:21:06Z")

</div>

> // vtkNew, in contrast to vtkSmartPointer, has no assignment operator  
> // or copy constructor and owns one object for its whole lifetime.  
> // Thus vtkNew does not satisfy the CopyAssignable and CopyConstructible  
> // requirements needed for other std containers like std::vector or std::list.  
> // std::array, on the other hand, is a container encapsulating fixed size  
> // arrays so its elements do not need to be CopyAssignable and  
> // CopyConstructible.

Good news, this is no longer true – all of the VTK smart pointers, including `vtkNew` are usable with `std::vector`.

In C++11, the wording of `std::vector<T>`'s restrictions on the `T` type changed to remove the bits about `CopyAssignable` and `CopyConstructible`. [The only remaining hard restriction is `Erasable`, any other requirements depend on how the container is actually used](http://eel.is/c++draft/vector). While there are a few methods that explicitly require `T` to be copyable (e.g. `std::vector::resize(size_type, const T&)`), most only require that `T` is [`MoveInsertible`](http://eel.is/c++draft/container.requirements).

All of the VTK smart pointers are `MoveInsertible` as of [this commit](https://github.com/Kitware/VTK/commit/30605cd78d9a36f67dbf7c0c9d54e879d908ce8c#diff-46ecb7dc758f8a8aa0fdef732ed40087ac1e96ca42c83f7b7d70465d53b1c1b7R90-R109) and can be used in a `std::vector`, and `vtkNew<T>` can now be treated like any other move-only container. This came up a while ago [in a post](https://discourse.vtk.org/t/vtknew-and-vtksmartpointer/469/9) that discussed the changes. If you read that link, note that while you _can_ return a `vtkNew` from a function, it’s easy to misuse since the issue mentioned in that thread was never resolved.

---

_[View the full topic](https://discourse.vtk.org/t/page-about-vtksmartpointer/4449)._
