[vtk-developers] const correctness

tom fogal tfogal at sci.utah.edu
Thu Feb 10 15:09:31 EST 2011


"Sean McBride" <sean at rogue-research.com> writes:
> On Thu, 10 Feb 2011 12:50:49 -0500, Berk Geveci said:
> Maybe I'm just not enough of a C++ expert, but I don't get this:
> 
> <http://review.source.kitware.com/#patch,unified,882,1,Common/
> vtkInformationDoubleKey.cxx>
> 
> Why add the 2nd Get with an identical implementation?

It might not be needed, to be honest.  If it is, though, the
most likely explanation is that vtkInformation.cxx had a const
vtkInformation* and needed to pass it into the Get method.

It could also be that vtkInformation.cxx needed to pass in a mutable
info object at some point or another.

It could be that the const version is the only one that is ever used
and the mutable one is not needed for either use or interface && should
just then be deleted.

It could be that the mutable version is needed for interface but in
reality only the const version needs to be used, i.e. the mutable one
should be deleted by that class and all superclasses.

(Certainly the implementation is substandard: in this case, we should
have a constant method that accepts the GetAsObjectBase return value
and does the ternary operator itself, then implement both of these
methods to call that new method.  We're getting OT now, though...)

Anyway, I'll add "investigate this" to my list, but from all the emails
in this thread: my list is getting fairly huge :).  Help wanted, apply
within.

-tom



More information about the vtk-developers mailing list