That would necessitate either vtkObject losing its internal refcount or using something like boost::intrusive_ptr. I suppose it could inherit from shared_from_this to get what it wants, but even that is unnecessary overhead I feel. But just migrating to shared_ptr would mean lots of API churn. The easy fix of passing shared_ptr around everywhere really sucks and is a really bad code smell and VTK isn’t all that good about indicating ownership or sharing through its API types (using T& return values to indicate “this is just a reference; you need to keep me around if you want to keep using that” and (const) T& as a parameter for “I just need to look; I won’t increment the refcount”).
2 Likes