[Bug libstdc++/78231] Should std::sort use unqualifed iter_swap?

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 8 19:07:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78231

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Eric Niebler from comment #6)
> Jonathan, the wording for std::reverse mentions iter_swap and doesn't seem
> to say whether it is called qualified or unqualified.

17.6.1.1 [contents] means it calls it qualified as ::std::iter_swap, unless
otherwise specified. AFAICS it isn't otherwise specified.

> AFAIK, it is the only
> algorithm that is required to use iter_swap. It seems to be a hold-over from
> a time before time. The requires clause says that *value must be swappable,

Which does mean an unqualified call to swap happens, as per 17.6.3.2
[swappable.requirements].

> but it doesn't *exactly* say that the call to iter_swap must resolve to the
> version in namespace std that does swap(*a,*b). Please forgive me if I'm
> misreading the standard.

The standard library always assumes qualified calls to avoid ADL, unless
otherwise specified (as done for swap in [swappable.requirements]).


More information about the Gcc-bugs mailing list