Is there a standard way to compare two references for identity implementing essentially what is done bellow:
bool compareForIdentity(int& a,int& b){return &a==&b;}
Is there a standard way to compare two references for identity implementing essentially what is done bellow:
bool compareForIdentity(int& a,int& b){return &a==&b;}
If you want to ensure that the references do not refer to the same object then yes, comparing the addresses as you have shown is indeed the standard way. The (built-in) address operator returns the address of the object referred to, not the address of the reference (which can conceptually be considered just another name without any object representation). This is the semantics usually needed to e.g. ensure a NOP for a copy to itself.
To ensure that indeed the built-in address operator is used (as opposed to any overloads) seems to be possible if a little tricky, cf. How can I reliably get an object's address when operator& is overloaded?.
Other uses may of course require different semantics, e.g. logical equality instead of physical.