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

The Archive Base Latest Questions

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

Possible Duplicate: What is move semantics? I recently attended a C++11 seminar and the

  • 0

Possible Duplicate:
What is move semantics?

I recently attended a C++11 seminar and the following tidbit of advice was given.

when you have && and you are unsure, you will almost always use std::move

Could any one explain to me why you should use std::move as opposed to some alternatives and some cases when you should not use std::move?

  • 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-17T19:18:33+00:00Added an answer on June 17, 2026 at 7:18 pm

    First, there’s probably a misconception in the question I’ll address:
    Whenever you see T&& t in code (And T is an actual type, not a template type), keep in mind the value category of t is an lvalue(reference), not an rvalue(temporary) anymore. It’s very confusing. The T&& merely means that t is constructed from an object that was an rvalue 1, but t itself is an lvalue, not an rvalue. If it has a name (in this case, t) then it’s an lvalue and won’t automatically move, but if it has no name (the result of 3+4) then it is an rvalue and will automatically move into it’s result if it can. The type (in this case T&&) has almost nothing to do with the value category of the variable (in this case, an lvalue).

    That being said, if you have T&& t written in your code, that means you have a reference to a variable that was a temporary, and it is ok to destroy if you want to. If you need to access the variable multiple times, you do not want to std::move from it, or else it would lose it’s value. But the last time you acccess t it is safe to std::move it’s value to another T if you wish. (And 95% of the time, that’s what you want to do). All of this also applies to auto&& variables.

    1. if T is a template type, T&& is a forwarding reference instead, in which case you use std::forward<T>(t) instead of std::move(t) the last time. See this question.

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

Sidebar

Related Questions

Possible Duplicate: How to get notified of UITableViewCell move start and end I have
Possible Duplicate: Move existing, uncommited work to a new branch in Git I have
Possible Duplicate: C++11 rvalues and move semantics confusion What I think is correct is
Possible Duplicate: initializer_list and move semantics In this code: #include <vector> #include <initializer_list> template<typename
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: PHP - add item to beginning of associative array have associative array:
Possible Duplicate: JavaScript move delay and multiple keystrokes I'm new and learning HTML5 canvas
Possible Duplicate: What can I do with a moved-from object? After you called std::move
Possible Duplicate: Is array name a pointer in C? char arr[1024]; arr++ //move arr
Possible Duplicate: SpecFlow/BDD for Unit Tests? Over the last few years I have worked

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.