Can't bind lvalue to rvalue reference

时光怂恿深爱的人放手 提交于 2019-12-01 04:47:45

Quote from WIKI

For safety reasons, some restrictions are imposed. A named variable will never be considered to be an rvalue even if it is declared as such. To get an rvalue, the function template std::move() should be used. Rvalue references can also be modified only under certain circumstances, being intended to be used primarily with move constructors.

Anything that has a name is an lvalue reference. You have to use std::move on parameters to pass them on as rvalue references.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!