std::move() is just casting?

前端 未结 2 1632
执笔经年
执笔经年 2021-01-21 06:56

I have read a few (pesudo) implementions of std::move(). And all are just casting away the reference of the parameter and then returning it as a rvalue reference.

It do

2条回答
  •  無奈伤痛
    2021-01-21 07:36

    Yes, that's exactly as it is described in the standard. In N4659 (which is last draft I found)

    it says in §23.2.5

    template constexpr remove_reference_t&& move(T&& t) noexcept;

    Returns: static_cast&&>(t)

    It doesn't mark anything for destruction, and it doesn't change the object but object may be changed in function that accepts rvalue (such as move constructor, move assignment operator)

提交回复
热议问题