Can't understand the implementation of std::move

Viewed 1947

Here is a possible implementation of std::move(). It's not fully conforming to the details of the standard, but it's very close:

template<class T>
typename std::remove_reference<T>::type&&
myMove( T&& Arg )
{   
    return ( ( typename std::remove_reference<T>::type&& )Arg );
}

I don't understand why it wouldn't work if we replace typename std::remove_reference<T>::type&& by the T&&, i.e.

template<class T>
typename std::remove_reference<T>::type&&
myMove( T&& Arg )
{   
    return ( (T&&) Arg );
}
1 Answers
Related