This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why doesn't iter_swap use swap?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]