[Insight-developers] ITK Iterator, const_cast & STL compatibility
Gert Wollny
gert at die.upm.es
Wed Aug 27 02:02:16 EDT 2008
Hi Luis,
I'm still alive and thinking about the iterator/const_cast/STL
problem. However, I was a bit busy with other stuff.
I came to the conclution that the read-write operator should not be
derived from the const iterator. Deriving usually describes an "is-a"
relationship and by deriving a specialisation of a common base is
provided. Obviously a RW iterator is more then a const iterator, and
thereforethe const_cast is needed, to provide the RW property.
I've had a look at the GNU std::__normal_vector implementation, and
what they do is to use an additional template parameter to provide the
internal pointer either as const or non-const pointer.
In addition, an additional constructor is provided that enables
iterator to const_iterator conversion.
Since the using directive to define partial specialized template names
will only be included in C++0x standard, adding a template parameter
to the iterator classes would require a change to the whole library
and all end-user software.
Since this is obviously not an option at this point in time, I would
do a reimplementation that would result in some code duplication for
the time being. This reimplementation would then, of course, also
target for STL-compatibility.
Best
Gert
More information about the Insight-developers
mailing list