小编lin*_*fil的帖子

Why is std::remove_reference used in std::move?

I tried implementing std::move, which uses std::remove_reference, however it seems to work without it. Please, give me an example in which my implementation will fails whithout std::remove_reference.

template <class type> type && move(type & source) { return (type &&) source; }
template <class type> type && move(type && source) { return (type &&) source; }
Run Code Online (Sandbox Code Playgroud)

Is std::remove_reference used only to avoid overloading std::move?

Here is a test class to help you:

class test {
public : …
Run Code Online (Sandbox Code Playgroud)

c++ syntax reference move-semantics

6
推荐指数
1
解决办法
1065
查看次数

标签 统计

c++ ×1

move-semantics ×1

reference ×1

syntax ×1