From: Eljay Love-Jensen <eljay@adobe.com>
To: John Fine <johnsfine@verizon.net>
Cc: GCC-help <gcc-help@gcc.gnu.org>
Subject: Re: Is this code wrong?
Date: Sat, 09 Aug 2008 02:44:00 -0000 [thread overview]
Message-ID: <C4C26A03.7BBB%eljay@adobe.com> (raw)
In-Reply-To: <489CC728.5040603@verizon.net>
Hi John,
The style that you indicated...
Foo ReturnAFoo()
{
Foo foo;
return foo;
}
void DoSomething()
{
Foo const& foo = ReturnAFoo();
foo.AreYouStillHere(); // Yep, still here.
}
...is good.
The temporary returned by ReturnAFoo in DoSomething is bound to the
reference.
It won't be destructed until the reference goes out of scope. Really.
I use that style often.
(Although I can't cite chapter+verse of ISO 14882.)
HTH,
--Eljay
next prev parent reply other threads:[~2008-08-09 2:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 6:55 odd behavior with Character Arrays Rohit Arul Raj
2008-08-08 7:07 ` Mateusz Loskot
2008-08-08 9:38 ` Rohit Arul Raj
2008-08-08 12:10 ` Jędrzej Dudkiewicz
2008-08-08 13:00 ` Mateusz Loskot
2008-08-08 13:40 ` Mateusz Loskot
2008-08-08 15:01 ` John Fine
2008-08-09 1:09 ` Is this code wrong? John Fine
2008-08-09 2:44 ` Eljay Love-Jensen [this message]
2008-08-09 11:23 ` corey taylor
2008-08-09 14:57 ` John Fine
2008-08-08 15:38 ` odd behavior with Character Arrays Bob Plantz
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=C4C26A03.7BBB%eljay@adobe.com \
--to=eljay@adobe.com \
--cc=gcc-help@gcc.gnu.org \
--cc=johnsfine@verizon.net \
/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).