In the Google C++ Style Guide, there’s a section on Operator Overloading that has a curious statement:
Overloading also has surprising ramifications. For instance, you can’t forward declare classes that overload
operator&.
This seems incorrect, and I haven’t been able to find any code that causes GCC to have a problem with it. Does anyone know what that statement is referring to?
5.3.1 of the Standard has ‘The address of an object of incomplete type can be taken, but if the complete type of that object is a class type that declares operator&() as a member function, then the behavior is undefined (and no diagnostic is required).’
I didn’t know this either, but as another poster has pointed out, it’s easy to see how it could cause a compiler to generate incorrect code.