[Insight-developers] ITK Iterator, const_cast & STL compatibility

Luis Ibanez luis.ibanez at kitware.com
Wed Aug 27 08:02:37 EDT 2008


Hi Gert,

Thanks for letting us know about your progress in this front.

We look forward to see the STL compatible implementation,
and to explore mechansims for making it compatible with
the existing code.


   Regards,


      Luis


------------------
Gert Wollny wrote:
> 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
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
> 


More information about the Insight-developers mailing list