Suppose I have:
void function1( Type* object ); //whatever implementation
void function2( Type& object )
{
function1( &object );
}
supposing Type doesn’t have an overloaded operator &() will this construct – using operator & on a reference – obtain the actual address of the object (variable of Type type) on all decently standard-compliant C++ compilers?
Yes, and the reason is that on the very beginning of evaluating any expression, references are being replaced by the object that’s referenced, as defined at
5[expr]/6in the Standard. That will make it so the&-operator doesn’t see any difference:This makes it so that any operator that operates on an expression “sees through” the reference.