[Insight-developers] ImageRandomNonRepeatingConstIteratorWithIndex segfault

Williams, Norman K norman-k-williams at uiowa.edu
Tue Mar 1 11:50:17 EST 2011


I think that the 'principal of least astonishment' would require that a
working assignment operator should exist for this class.

It's truly the case that anyone who learned ITK from reading examples and
documentation would usually do something like

IteratorType it(image,image->GetLargestPossibleRegion());

but

IteratorType it = IteratorType(image,image->GetLargestPossibleRegion());

is legal syntax, compiles without warnings, and in this case, failed.

As library designers, our response shouldn't be "why would you want to do
that?" if for no other reason than it's not possible to envision every
conceivable use case.  If we want to disallow the second usage, we should
do it by using C++ language to prevent it. Otherwise, we have to support
it.

Luis is right that one normally wouldn't make an iterator a class member.
But copying iterators by assignment is perfectly valid -- for example to
use them as 'bookmarks' into an image.



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list