Topic: Question about defect report 187 (iter_swap)
Author: "Bill Wade" <bill.wade@stoner.com>
Date: 2000/05/11 Raw View
DR 187 (library) resolves an ambiguity in the standard by saying that
iter_swap(i,,j) must call swap(*i,*j). Dave Abrahams had pointed out this
resolution prevents an optimization for list iterators (implement iter_swap
in terms of splice). A similar optimization for deques of large objects
(where each "page" contains only one object) also becomes prohibited.
This isn't the choice I would prefer (I'd like to give the implementer the
freedom to perform the optimization) but I could work around it if there
were a reasonable way for me to override the behavior. In some cases I'd be
willing to write my own container and specialize iter_swap on my iterators
so that I'd get a splice-like operation. However, 17.4.3.1/1
(specializations must meet the requirements of the unspecialized template)
seems to say I can't even do that. It would seem that if I specialize
iter_swap in such a way that it does not call swap, I get undefined
behavior.
Am I correct about the interaction between DR 187 and 17.4.3.1/1?
Is there a good reason for the interaction (perhaps somebody's
implementation of sort() uses references internally instead of iterators?
The Tokyo note to issue 198 (validity of references) would seem to imply
that is not the case)?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]