[Insight-developers] Const/nonConst Iterator

Luis Ibanez luis.ibanez@kitware.com
Wed, 17 Apr 2002 18:31:40 -0400


Miller, James V (Research) wrote:

>I am assuming in your code below that instead of 
>
>ImageConstIterator< ImageType >  it( myConstImage, region );
>it.GoToBegin();
>
>you meant
>
>ImageIterator< ImageType >  it( myConstImage, region );
>it.GoToBegin();
>
Yes, that's what I meant,
Thanks for the correction.

>
>
>So a non-const iterator can be passed a const image and will
>allow someone to call Set() to a const image.
>
>I think the solution is in the non-const version provide 
>a constructor that takes a const Image but put that constructor
>in the private section so that it can never be called.
>
That's a good option too.

I have already set up a : ImageIteratorBase which factorize the
common code between the const and non-const version.
So the three classes are defined in the same header file.

I'm still dealing with some details with the PixelAccessors...


Luis