On Mon, 23 Feb 2009 16:36:28 -0800, jitter <jitter@jitter.com>
wrote:
For years, I have had the mistaken idea that passing a reference
would invoke a copy constructor.
Lesson learned!
References are not objects, and you can't "pass them". It's more
accurate to think in terms of "passing by reference" and "returning
by reference", and the implicit "what" in these phrases is
"objects". The association of a reference with an object is
immutable and called "binding". It is possible for a temporary
object to be created when an object of type X is bound to a const
reference of a different type Y; this will happen when X is
convertible to Y and isn't derived from Y. Otherwise, you're right,
and reference binding can be considered an almost free operation.
(Under the hood, references are typically implemented in terms of
pointers.)