Re: Can 'qsort' have an advantage over 'std::sort'?
johnchx2@yahoo.com wrote:
kanze wrote:
johnchx2@yahoo.com wrote:
I thought that this might be the case, but (a) I can't find
any requirement in the standard that it do so and (b) the
implementations I have handy (STLPort and libstdc++) appear
to require the copy constructor and assignment operator,
even though I provide a suitable swap() overload.
Well, that's a requirement of the standard.
How so? I actually expected to find requirements similar to
those for the standard containers (assignable and copy-able)
but if they're there, I overlooked them. The iterators are
required to be mutable, but I didn't see any requirement that
their value types be assignable or copyable. What am I
missing?
I can't find them either. What I think is required is that the
iterators be dereferenciable -- if not, they're not
RandomAccessIterators. If it1 and it2 are random access
iterators, the expression *it1 = *it2 must be legal. As it
stands, however, I think the standard requires std::sort to work
even when the value type is neither copy constructable nor
default constructable, and doesn't have a specialization for any
sort of swap. Which is, I think, an impossible condition.
Howard Hinnant has mentionned a defect report, but I don't think
it covers this issue.
--
James Kanze kanze.james@neuf.fr
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]