C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Member function, using, and ADL
From: Edward Catmur (ecatmur_at_[hidden])
Date: 2021-05-29 12:27:12


On Sat, 29 May 2021 at 18:03, Ville Voutilainen <ville.voutilainen_at_[hidden]>
wrote:

> On Sat, 29 May 2021 at 19:16, Edward Catmur via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
>
> > That is, the point of "using std::swap;" is twofold; it both hides any
> class member "swap", and makes "std::swap" available as a fallback if ADL
> does not find a suitable candidate. But ADL-located candidate names are
> preferred.
>
> No they're not, the call is overload-resolved. The ADL-located
> candidates win if they're better matches, but
> there's no preference for them otherwise. See
> https://wandbox.org/permlink/CuYwIMxcXv3RZA4k

Yes, thanks for the correction. I was assuming that the ADL-located
candidates would be better matches (e.g. if they're more specialized or
constrained than std::swap), but that isn't always going to be the case.



STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups