[vtk-developers] Smart pointer declaration macro?

Brad King brad.king at kitware.com
Thu Jan 28 11:42:16 EST 2010


Timothy M. Shead wrote:
> 
>> 4. Make a new vtkLocalPointer type that is the same as vtkSmartPointer
>> but always creates an instance of the object.
>> vtkLocalPointer<vtkClass> c;
> 
> Muddying the waters further, I might suggest vtkScopedPointer as a
> better name for this alternative, one that is at least consistent with
> boost.

The boost::scoped_ptr does not allow transfer of ownership or shared
ownership semantics.  The proposed vtkLocalPointer supports shared
ownership; it's meant to be a vtkSmartPointer (~= boost::shared_ptr)
that just allocates on construction.  See my other responses for why
this is not a good idea.

> inclined to cleanup the API a bit ... I find that between Take(),
> TakeReference(), and the current assignment operator that it always
> seems to take me two tries to use it without leaks / premature destruction.

Those methods are necessary to interact with VTK's APIs that use raw
pointers and implicit transfers of ownership.

-Brad



More information about the vtk-developers mailing list