
11 Jun
2012
11 Jun
'12
11:25 a.m.
On Mon, Jun 11, 2012 at 1:22 PM, Mathias Gaunard <mathias.gaunard@ens-lyon.org> wrote:
According to this rule, I should pass by value whenever I want to copy the variable anyway.
template<class T> struct foo { T t; foo(T t_) : t(t_) {} };
Shouldn't you use std::move here to ensure t_ is moved into t (if possible)?
Clearly we can see this code causes one copy with rvalues, two with lvalues, instead of always one if we used const-reference.
The only instance where this might be useful is operator=, and then again, it's probably still a bad idea.
-- Olaf