Is there a cast (or standard function) with the opposite effect to `std::move`

前端 未结 4 1439
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 14:02

First off, this question is not a duplicate of Function dual to std::move? or of Does the inverse of std::move exist?. I am not asking about a mechanism to

4条回答
  •  抹茶落季
    2021-01-18 14:57

    This appears to work in all of your cases:

    template 
    constexpr typename std::remove_reference::type& copy(T&& t) {
        return t;
    };
    

    It's exactly like std::move, except it returns an lvalue reference instead.

提交回复
热议问题