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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:59:49+00:00 2026-05-25T11:59:49+00:00

I got next snippet from microsoft template <typename T> struct RemoveReference { typedef T

  • 0

I got next snippet from microsoft

template <typename T> struct RemoveReference {
     typedef T type;
};

template <typename T> struct RemoveReference<T&> {
     typedef T type;
};

template <typename T> struct RemoveReference<T&&> {
     typedef T type;
};

template <typename T> typename RemoveReference<T>::type&& Move(T&& t) {
    return t;
}

…

remote_integer x = frumple(5);
remote_integer&& x1 = Move(x);

and i get an error “error C2440: ‘return’ : cannot convert from ‘remote_integer’ to ‘remote_integer &&'”

something changed in compilers? With std::move all goes right.

  • 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-05-25T11:59:50+00:00Added an answer on May 25, 2026 at 11:59 am

    The reason your Move doesn’t work, is because t is always lvalue (even when T&& resolves to, say, int&&). Even though it might seem weird, named rvalue references are indeed lvalues.

    When returning from your Move, you attempt to implicitly bind lvalue to rvalue reference, which is forbidden by standard (§8.5.3). As noted in the comments, you have to cast t explicitly to rvalue reference.

    Relevant parts of standard are §5/4 and §5/5, but I’m going to quote note §5/6, which sums this nicely:

    In general, the effect of this rule is that named rvalue references
    are treated as lvalues and unnamed rvalue references to objects are
    treated as xvalues; rvalue references to functions are treated as
    lvalues whether named or not.

    Correct implementation is indeed:

    template <typename T>
    typename std::remove_reference<T>::type&& move(T&& t)
    {
      return static_cast<typename std::remove_reference<T>::type&&>(t);
    }
    

    As far as I remember, this code used to be valid in earlier drafts. But since the rules have changed, you have to provide explicit cast now (same applies to std::forward).

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

Sidebar

Related Questions

Got next template in separate file section.htm: <h3>${Name}</h3> {{each Variables}} {{tmpl($data) Type}} ${Type} |
I've got the next SQL query: SELECT FIRST_NAME, LAST_NAME FROM MYTABLE WHERE STATUS =
I got code snippet from this site, which I used as shown below $data
I've got the next problem up from this one: Comparing date ranges The solution
I've got the following in my .css file creating a little image next to
I've got two spans in a div. I want to align them next to
Say you've got two simple table cells next to each other. One contains a
I've the next problem: I've got a div which contains an image. I need
I've got a photo slideshow with thumbnails. Next/Previous buttons appear and disappear based on
I got this next problem. I have a binary file, which I write to

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.