rsmith added a comment.

dlj and I discussed this offline somewhat, and dlj made the interesting point 
that using ADL *at all* within the implementation of the standard library 
brings with it the risk that your implementation will not function correctly if 
a user-declared operator could be at least as good a match as your intended 
callee.

As an example, consider: https://godbolt.org/g/rgFTME -- as far as I can see, 
that code follows all the rules for safe and correct use of the C++ standard 
library. And yet it does not compile with either libc++ or libstdc++, because 
both internally use ADL to find the `operator!=` for `vector::iterator` within 
their implementation of `vector::erase`. Any ADL call seems likely to suffer 
from this problem; moreover, you can observe that `vector<Foo>::iterator` fails 
to even satisfy the input iterator requirements, because `a != b` is not a 
valid expression for iterators `a` and `b`.

I think the above example is actually demonstrating a bug in the standard: such 
user code is unreasonable and it's not sensible to expect the standard library 
to cope with it.


https://reviews.llvm.org/D37538



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to