[vtk-developers] vtk-developers Digest, Vol 158, Issue 21

Andras Lasso lasso at queensu.ca
Sat Jun 24 09:53:19 EDT 2017


Based on the feedbacks and the poll results (11 out of 13 votes for changing current behavior), it seems there is a strong consensus  
for adding implicit conversion.

Here is a pull request with the change:
https://gitlab.kitware.com/vtk/vtk/merge_requests/2961

Andras

-----Original Message-----
From: David Lonie [mailto:david.lonie at kitware.com] 
Sent: Friday, June 23, 2017 1:51 PM
To: Shawn Waldon <shawn.waldon at kitware.com>
Cc: Andras Lasso <lasso at queensu.ca>; VTK Developers <vtk-developers at vtk.org>; Andrew Maclean <andrew.amaclean at gmail.com>
Subject: Re: [vtk-developers] vtk-developers Digest, Vol 158, Issue 21

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