> ADL is used whenever you write
    std::string s;
    auto t = s + s;  // ADL on operator+
    std::cout << s;  // ADL on operator<<
    swap(s, s);  // ADL on swap

In particular, the "std::swap two-step" is used inside all swap-based STL algorithms, such as std::rotate and std::sort.
So you can't actually turn it off, because then you'd break the world (because approximately every C++ program depends on ADL somewhere). But you could issue a warning about it outside of system headers, just to get a sense of the magnitude of the issue.

> –Arthur

Perhaps this is why I have written "not-a-minority not using std lib" :) ... you know those pesky C++ projects using -fno-exceptions or even using things like EASTL (gasp! again). I am not a "just-say-no-to-adl" zealot, I am just developing your very same idea further. Let's see where that takes us. Perhaps that might lead to some solution about removing the heavy technical debt of ADL.

Enough said, peace

DBJ



On Tue, 13 Oct 2020 at 21:30, Arthur O'Dwyer <arthur.j.odwyer@gmail.com> wrote:
On Tue, Oct 13, 2020 at 10:57 AM Dusan Jovanovic (DBJ) <dbj@dbj.org> wrote:
A.O.D. has written: -- I'd be interested to see a compiler patch to warn whenever "ADL lookup occurred, on a non-operator, and ADL found a best-matching candidate which would not have been found by regular unqualified lookup." It couldn't be used in production because approximately every C++ program depends on ADL somewhere. But it could give us a sense of the magnitude of the issue. --

Why not just going further: -fno-adl

That would certainly "rock the boat". In my not-a-compiler-writer naivete, I might think, contrary to A.O.D. (gasp!) a lot of code will work unbroken with that switch.? Especially that silent not-minority not using std lib.

ADL is used whenever you write
    std::string s;
    auto t = s + s;  // ADL on operator+
    std::cout << s;  // ADL on operator<<
    swap(s, s);  // ADL on swap

In particular, the "std::swap two-step" is used inside all swap-based STL algorithms, such as std::rotate and std::sort.
So you can't actually turn it off, because then you'd break the world (because approximately every C++ program depends on ADL somewhere). But you could issue a warning about it outside of system headers, just to get a sense of the magnitude of the issue.

–Arthur