[llvm-bugs] [Bug 47333] templetized operator<< isn't matched in a namespace

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 27 10:53:21 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47333

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
This is just how C++ operator lookup works, I'm afraid. It's not designed to
let you customise the behavior of an operator on types that you don't control.

The operator in `os << ee` is looked up as if it were written `operator<<(os,
ee)`. That lookup performs two checks:

1) What can we find by unqualified lookup? That is, search outwards through
scopes until you find a declaration of `operator<<` and stop there. This finds
the declaration in the namespace if present, and finds the declaration at
global scope otherwise.

2) Perform argument-dependent lookup: this looks for any `operator<<` declared
in a namespace associated with any argument (in this case, that's only
namespace `std`) and look for hidden friends of classes involved in the
argument types.

Neither lookup finds your ::operator<< when X::operator<< is declared.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200827/ef38227b/attachment.html>


More information about the llvm-bugs mailing list