move semantics std::move how use it

前端 未结 2 815
广开言路
广开言路 2021-01-20 18:10
#include 

template
typename std::remove_reference::type&& move(T&& v)
{
    return v;
}

void main()
{
           


        
2条回答
  •  一整个雨季
    2021-01-20 18:52

    This is straight out of the C++0x draft standard (§20.2.3/6):

    template typename remove_reference::type&& move(T&& t) noexcept;

    Returns: static_cast::type&&>(t).

    Consequently, if you change your move implementation to the following, it works just fine:

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

提交回复
热议问题