This is the mail archive of the
mailing list for the libstdc++ project.
Re: Why doesn't iter_swap use swap?
- From: chris <caj at cs dot york dot ac dot uk>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Sun, 22 Aug 2004 10:14:03 +0100
- Subject: Re: Why doesn't iter_swap use swap?
- References: <41285BF9.email@example.com>
Hello self :)
Just to pad out my earlier mail, it looks like intel's implementation
does use swap to implement iter_swap, and stlport's implementation
requires the two parameters to iter_swap must have the same type (unlike
There is also a defect report against iter_swap (
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html , defect
187 ), which discusses how to be honest it's a bit of a mess.
I see this has been previously posted about but wasn't discussed in
depth. However for performing STL algorithms in constructs of any kind
of complexity I imagine this is causing some serious dents in performance.
One reason discussed in the standard about why not to use swap() is that
iter_swap may work in some places where swap() doesn't (vector<bool> is
mentioned). I'm not an expert on this, but we seem to in general require
"normal assignment" in for example __unguarded_linear_insert, and other
I'm happy to continue investigating this, but I suspect someone else
might be able to advise quickly what is going on. If it turns out that
we can't or won't change iter_swap in general, then a large number of
overloads may have to be defined as at the moment many algorithms are
not using swap and are therefore much more expensive than they should be.