Named Return Value Extension Proposal
Bill Currie
bcurrie@tssc.co.nz
Wed Mar 31 23:46:00 GMT 1999
E. Robert Tisdale wrote:
> Not quite. The function prototype is X g0(X);
> which means that the compiler creates a temporary
> for argument X when X g0(X) is called
> then the copy constructor is called to initialize
> the return value for g0(X) before entering
> the body of the function.
Uh huh, and just why are you declaring your function as X g0(X) anyway?
You would be much better off declaring it as X g0(const X&), which will
prevent the creation of a temporary (this is exacty what const& was
designed for, AIUI). const & is your (and the compiler's) friend.
Bill
--
Leave others their otherness
More information about the Gcc
mailing list