public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bill Currie <bcurrie@tssc.co.nz>
To: "E. Robert Tisdale" <edwin@netwood.net>
Cc: egcs@egcs.cygnus.com
Subject: Re: Named Return Value Extension Proposal
Date: Mon, 22 Mar 1999 21:14:00 -0000	[thread overview]
Message-ID: <36F72380.D8230871@tssc.co.nz> (raw)
In-Reply-To: <36F712BA.C6A41522@netwood.net>

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

WARNING: multiple messages have this Message-ID
From: Bill Currie <bcurrie@tssc.co.nz>
To: "E. Robert Tisdale" <edwin@netwood.net>
Cc: egcs@egcs.cygnus.com
Subject: Re: Named Return Value Extension Proposal
Date: Wed, 31 Mar 1999 23:46:00 -0000	[thread overview]
Message-ID: <36F72380.D8230871@tssc.co.nz> (raw)
Message-ID: <19990331234600.aGZhJfua62_uCzScT8UH0o7vwsjhfaZILbpqLDKalKo@z> (raw)
In-Reply-To: <36F712BA.C6A41522@netwood.net>

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

  reply	other threads:[~1999-03-22 21:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-22 19:37 Mike Stump
1999-03-22 20:07 ` E. Robert Tisdale
1999-03-22 21:14   ` Bill Currie [this message]
1999-03-31 23:46     ` Bill Currie
1999-03-31 23:46   ` E. Robert Tisdale
1999-03-31 23:46 ` Mike Stump
  -- strict thread matches above, loose matches on Subject: below --
1999-03-23  6:43 Mike Stump
1999-03-23  9:00 ` E. Robert Tisdale
1999-03-31 23:46   ` E. Robert Tisdale
1999-03-31 23:46 ` Mike Stump
1999-03-22 18:58 E. Robert Tisdale
     [not found] ` < 36F7029D.F0EE48E8@netwood.net >
1999-03-22 19:14   ` Mark Mitchell
     [not found]     ` < 199903230316.TAA05276@adsl-206-170-148-33.dsl.pacbell.net >
1999-03-23  1:05       ` Martin v. Loewis
1999-03-31 23:46         ` Martin v. Loewis
1999-03-31 23:46     ` Mark Mitchell
1999-03-22 19:39 ` Gabriel Dos Reis
1999-03-31 23:46   ` Gabriel Dos Reis
1999-03-31 23:46 ` E. Robert Tisdale
1999-03-22 18:57 Mike Stump
1999-03-22 19:08 ` E. Robert Tisdale
1999-03-31 23:46   ` E. Robert Tisdale
1999-03-31 23:46 ` Mike Stump
1999-03-22 13:10 E. Robert Tisdale
1999-03-22 16:59 ` Gabriel Dos Reis
1999-03-31 23:46   ` Gabriel Dos Reis
1999-03-31 23:46 ` E. Robert Tisdale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36F72380.D8230871@tssc.co.nz \
    --to=bcurrie@tssc.co.nz \
    --cc=edwin@netwood.net \
    --cc=egcs@egcs.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).