[vtk-developers] vtk-developers Digest, Vol 158, Issue 21
David Lonie
david.lonie at kitware.com
Fri Jun 23 13:50:55 EDT 2017
I'm so glad someone brought this up =)
On Fri, Jun 23, 2017 at 10:52 AM, Shawn Waldon <shawn.waldon at kitware.com> wrote:
> But realistically what it does is
> discourage use of vtkNew. Most people I talk to say "I would use vtkNew but
> then I have to clutter up my code with GetPointer calls everywhere" and so
> they still use vtkSmartPointer. Honestly I only used it to clean up
> declarations (the problem discussed earlier in this thread). Now that we
> can use auto in VTK, I'll probably go back to vtkSmartPointer since it is
> easier to use.
I agree with Shawn. It's an unnecessary hassle to require the Get() to be used.
I suppose I'm just a fan of the design philosophy for C++ about "don't
prevent developers from shooting themselves in the foot." If a dev
doesn't understand VTK's reference counting well enough to understand
that you can't simply return a vtkNew'd pointer without increfing it
first, they're going to have far greater problems using the toolkit
than this.
Besides, you could easily (and safely) return a vtkNew'd pointer from
a function:
vtkObject* function()
{
vtkNew<vtkObject> obj;
obj->Register();
return obj; // If we had implicit conversions, anyway
}
Making the class unwieldly simply so that people don't need to learn
how reference counts work is a poor justification IMO.
Just my 2c,
Dave
More information about the vtk-developers
mailing list