[vtk-developers] RFC: vtkScopedPointer - a new hope?

Marcus D. Hanwell marcus.hanwell at kitware.com
Tue Jan 25 13:22:58 EST 2011


On Tue, Jan 25, 2011 at 1:08 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Marcus,
>
> I think I understand your argument.
>
> However, I was looking for a simple drop-in similar to what Brad
> experimented with last March.
>
> I can't recall the details of his implementation nor why we abandoned it.
>
Bill,

Like I said, the proposed class intentionally lacks the implicit cast
to pointer operator. I think leaving it makes the use of it much more
error prone, although probably just as error prone as vtkSmartPointer
should you use that in your functions. The normal -> syntax works as
expected, and I would argue there is too much implicit casting in our
code already.

operator T* () const;

is the missing method in vtkNew to support implicit pointer casting.
We were looking at the old implementation, and this is what is missing
(intentionally) along with some extra assignment operator code/logic
so that,

vtkSmartPointer<vtkClass> a = vtkNew(vtkClass>;

would work, and this is what caused the problems (the assignment
operator for vtkSmartPointer). It still had the same repetition
issues, and personally I never appreciated the utility of this
particular use case other than saving some keystrokes.

Marcus



More information about the vtk-developers mailing list