C++ 常量右值有没有啥意义?
資深大佬 : by73 3
例如 void f(const T&& val) 这样的常量右值,虽然编译能通过,但总觉得语义上怪怪的,就想问问这种写法到底有没有意义,还是只是单纯的因为 reference collapsing 所以才保留这种写法?
(日常水,轻喷。。
大佬有話說 (3)
例如 void f(const T&& val) 这样的常量右值,虽然编译能通过,但总觉得语义上怪怪的,就想问问这种写法到底有没有意义,还是只是单纯的因为 reference collapsing 所以才保留这种写法?
(日常水,轻喷。。
1. we do not support the operation for lvalues!
2. even though, we still copy, because we can’t move the passed resource, or because there is no actual meaning for “moving” it.
真纠结