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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:47:14+00:00 2026-05-19T15:47:14+00:00

In the STL implementation of VS10 there is the following code for a variant

  • 0

In the STL implementation of VS10 there is the following code for a variant of std::swap():

    // TEMPLATE FUNCTION _Move
template<class _Ty> inline
    typename tr1::_Remove_reference<_Ty>::_Type&&
        _Move(_Ty&& _Arg)
    {   // forward _Arg as movable
    return ((typename tr1::_Remove_reference<_Ty>::_Type&&)_Arg);
    }

    // TEMPLATE FUNCTION swap (from <algorithm>)
template<class _Ty> inline
    void swap(_Ty& _Left, _Ty& _Right)
    {   // exchange values stored at _Left and _Right
    _Ty _Tmp = _Move(_Left);
    _Left = _Move(_Right);
    _Right = _Move(_Tmp);
    }

The cast to (typename tr1::_Remove_reference<_Ty>::_Type&&) in _Move() is the source of my question.

In this context _Remove_reference is defined as follows:

        // TEMPLATE _Remove_reference
template<class _Ty>
    struct _Remove_reference
    {   // remove reference
    typedef _Ty _Type;
    };

What does _Remove_reference do, and why?
Furthermore, what does && do here, and how is it termed?

  • 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-19T15:47:15+00:00Added an answer on May 19, 2026 at 3:47 pm

    _Remove_reference is a template that, well, removes the reference from its type. I’m pretty sure that the template is specialized for T& and T&& with the same typedef, right?

    Not sure how much I should go into details here. Are you familiar with template metaprogramming?

    _Move seems to do exactly what std::move does: it casts its argument to an rvalue. The point of the exercise is that std::swap can do moves instead of copies. Are you familiar with move semantics?

    what does && do here, and how is it termed?

    The term you are looking for is “rvalue reference”. Watch this video and come back with questions.

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

Sidebar

Related Questions

I'm using VS2005 and the MS implementation of STL. However, the class type_info in
Is std::string size() a O(1) operation? The implementation of STL I'm using is the
The STL commonly defines an output iterator like so: template<class Cont> class insert_iterator :
I am new to STL. I have written a Template Base class as follows
The forward declaration of STL library class std::queue is as follows: namespace std {
With the following implementation, I'm attempting to answer my question : class wlist {
The std::vector<T> class is a model of the STL Container concept, and as such
I freak out whenever I open up any STL-related code from Visual Studio's implementation
Have you used a checked STL implementation? Did it find bugs you were not
More specifically, does NDK have a complete STL implementation. We're looking at this for

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.