The linked question spells out two possible ways to implement a reference: as an alias or as a pointer. One reply says that there is no difference between the two from the programmer's perspective. It seems to me that this is not true:
- if reference is internally an alias, then passing by reference should have zero overhead (in which case, I would wonder why not pass an int by const reference instead of passing it by value).
- if reference is internally a pointer, then passing by reference costs copying the address (and passing an int by const reference would both cost copying the address and introduce an indirection).
Is my analysis correct? So what is a reference internally, alias or pointer?