[vtk-developers] Const correctness for string methods
Sebastien BARRE
sebastien at barre.nom.fr
Mon Jan 19 13:56:24 EST 2004
At 1/19/2004 10:36 AM, David Thompson wrote:
> > I don't think you can overload based on return value.
>You cannot, but the const-ness of the member function CAN be overloaded.
>For instance,
>
> double* GetPoint( vtkIdType );
> const double* GetPoint( vtkIdType ) const;
Const-correctness is a non-trivial topic in VTK: it's not that easy to
really tell if a method should be const-correct or not depending on what is
changed internally (for example). You could call a Get() method that looks
like a nice const-correct candidate, but have that Get() method trigger
another method that legitimately modifies attributes internally to perform
a computation (for example, bounds). Worst, you could have a chain of
methods that are all const-correct, but one day you change one call in the
final method, and that call has to be non-const, and then it breaks havoc
all along the chain. If I remember that behaviour can be handled through
'mutable' attributes (Brad), but I'm not sure we want to go that way...
More information about the vtk-developers
mailing list