[vtk-developers] Const correctness for string methods

David Thompson dcthomp at sandia.gov
Mon Jan 19 14:19:47 EST 2004


Bill Lorensen wrote:
> Tricky. I wonder of it's portable.
The only problem I can imagine is that some compilers may complain about
something like this:

	int GetFoo();
	const int GetFoo() const;

because a "const int" return type doesn't make sense. This could be
handled with an extra macro parameter or two versions of GetMacro.

Sebastien BARRE wrote:
> 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).
I agree, but by providing both a const and a non-const version,
everything should still work without changes and would allow const
member functions in a large number of cases.

		David




More information about the vtk-developers mailing list