Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:08:18+00:00 2026-06-15T13:08:18+00:00

I have spend a few hours about rvalue s and lvalue. Here is what

  • 0

I have spend a few hours about rvalue s and lvalue. Here is what I understand

int main()
{
  //.....
  Foo foo = Bar1();
  foo = Bar2();
  //......
}  

Foo Bar1()
{
  //Do something including create foo
  return foo;
}

Foo& Bar2()
{
  //Do something including create foo
  return foo;
}

Under c++03, Bar1() would copy the return object (just before return), and then return the address of the copied object; executing a wasteful copy of an object which is about to be destroyed. Bar2() would return the object created within the function.

Under c++11, Bar1() and Bar2() would essentially be equivalent (and also equivalent to Bar2() of c++03).

Is that right? If not, please elaborate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:08:19+00:00Added an answer on June 15, 2026 at 1:08 pm

    The concept of rvalues and lvalues didn’t change from older C++ to C++11. What you describe as “C++03” is what should happen. Some compiler optimizations in some cases can reduce the number of unnecessary copies (including unnecessary copy-constructor calls!), but otherwise it is the same.

    What did change is that C++11 introduced a concept of rvalue-reference (T&&).

    There are several articles on it that you can google up, for example over here:

    http://thbecker.net/articles/rvalue_references/section_01.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent quite a few hours reading and learning about LINQ to XML , but
I have spent last few hours trying to understand why my javascript timer is
Have spend quite some time to learn Sencha touch, just like an evaluation about
I have spend the last 1 or 2 hours diving into Java reflection. I
I know this is an old question, but I have spend any hours on
Am working on a small problem and have spent quite a few hours trying
I have a Winform which needs to wait for about 3 - 4 hours.
I'm trying to call web service for few hours. I have added clientaccesspolicy.xml: <?xml
I have a Java servlet from which I need to send few notifications to
I've spent the last few days banging my head and searching Google and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.