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

Elvis Stansvik elvis.stansvik at orexplore.com
Sat Jun 24 12:35:36 EDT 2017


2017-06-24 15:53 GMT+02:00 Andras Lasso <lasso at queensu.ca>:
> 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.

I was away and missed the vote, but frankly I'm not sure what I would
have voted.

Looking at what others do, I guess vtkNew is comparable to
std::unique_ptr or Qt's QScopedPointer, none of which do implicit
conversion to the underlying pointer (they have .get() and .data()
respectively). So VTK would be rather unique in doing that for a
scoped smart pointer I think..

Elvis

>
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>


More information about the vtk-developers mailing list