This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: Named Return Value Extension Proposal



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