After reading this answer, I am not really sure whether a reference actually does occupy memory or not. I get that it does not occupy memory when the the compiler replaces the references with the referenced variable, like swapping the reference with the referenced variable.
However,
In the general case, compilers usually implement references as pointers. But they generally have more information about what a reference may point to, and use that for optimization.
and since a pointer does occupy memory, won't that reference now result in occupying memory since the compiler made it a pointer? In the cases where the compiler chooses to make the reference a pointer instead of just swapping it, would it be valid to say that the reference actually does occupy memory but in a slight implicit way?
In fact, when does the compiler choose to implement references as pointers and not swapping, or is that different from compiler to compiler?