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 9267333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:31:38+00:00 2026-06-18T14:31:38+00:00

I have the following function: T foo(); And, in another function, I’m playing with

  • 0

I have the following function:

T foo();

And, in another function, I’m playing with the returned T value, like:

const T& t = foo();

or

T&& t = foo();

I want to ask:

  1. Are both equivalent?

  2. Memory-wise, what are the difference between these two approaches?

  3. I know that on the first approach the temporary value lifetime matches the reference lifetime. The same occurs when using the rvalue reference?

  4. Should I even consider using a const rvalue reference (const T&&)?

I’m using the first approach, that is what I’m used to and attends me fine. I’m still wrapping my head around rvalue references and C++11 goods.

  • 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-18T14:31:39+00:00Added an answer on June 18, 2026 at 2:31 pm
    1. No, they have different types.

    2. Implementation-defined, but there’s unlikely to be any difference.

    3. Lifetime extension works the same for rvalue and lvalue references. But the rule is more complicated than “the temporary value lifetime matches the reference lifetime”.

    4. Probably not. I certainly wouldn’t go looking for places to use it. If you have a use for it, it had better be such an significant improvement to justify the use of such an unusual combination and the confusion that will ensue when people read it in the future.

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

Sidebar

Related Questions

I have a bash function like the following: foo() { echo $1 } or
Say I have the following function: foo <- function(x, y = min(m)) { m
Suppose you have the following function foo . When I'm running a for loop,
Let's say we have the following function: foo <- function(x) { line1 <- x
I have the following code: <?php function foo($bar) { global $products; //$products = array();
I have the following structure $('foo').click( function() { var bool = false; $('bar').animate( function()
Suppose I have following code: def foo(s): A dummy function foo. For example: >>>
I have the following setup: abstract class AParentLy{ private $a; private $b; function foo(){
I have a vector of that looks like the following: class Foo { //whatever
I have a function with following signature char requestApiCall(int num, const wchar_t* pParams =

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.