This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Why doesn't iter_swap use swap?
- From: chris jefferson <caj at cs dot york dot ac dot uk>
- To: Daniel Frey <daniel dot frey at aixigo dot de>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 24 Aug 2004 09:43:06 +0100
- Subject: Re: Why doesn't iter_swap use swap?
- References: <41285BF9.1060004@cs.york.ac.uk> <cgerso$6d4$1@sea.gmane.org>
Daniel Frey wrote:
chris wrote:
Hello,
I suspect this might have a simple answer, but why doesn't iter_swap
use swap? I can't see any immediate disadvantages to this, and it
would have the major advantage that any specialisations of swap would
then be used by iter_swap (which is how I discovered the problem,
while trying to overload swap and then wondering why it wasn't
getting used by reverse and other algorithms...)
Chris
I'm currently discussing the same problem (swap, iter_swap and DR 187)
with some Boost folks. While it looks promising at first that
iter_swap uses ADL to find specializations, it is also intrusive for
the user as he can no longer protect calls from ADL by qualifying
them. Also, if a qualified call to iter_swap uses ADL internally, why
doesn't a qualified call to swap uses ADL, too? Technically it's
possible, Howard Hinnard already tried it out in the Metrowerks STL.
We are still undecided whether or not this is a good idea.
However, at least in stdlibc++, almost all uses of iter_swap are written
std::iter_swap. Therefore at the moment there is no way to user-defined
overloads, as users can't (or really, really shouldn't) put things in
std::, and iter_swap doesn't call swap. I think this is a worse situation
Chris