Re:Bjarne Stroustrup – The Essence of C++ [video]
by plorkyeran on Tuesday September 17, 2013 @10:14AM
(#6399371)
s isn't an rvalue. It has a name, and you can refer to it within the body of the constructor.
[ Parent
| on HN ]
Re:Bjarne Stroustrup – The Essence of C++ [video]
by a8da6b0c91d on Tuesday September 17, 2013 @10:23AM
(#6399428)
I understand that, but it's clearly not used in the body. I was hoping it would be a legal and implemented optimization.
move calls strike me as ugly and kinda dangerous. What if you do wind up wanting to refer to s in the body later on? It'd be nice if the compiler just handled it.
Re:Bjarne Stroustrup – The Essence of C++ [video]
by marshray on Tuesday September 17, 2013 @06:41PM
(#6402400)
> What if you do wind up wanting to refer to s in the body later on?
Then copy s, don't move it.
Re:Bjarne Stroustrup – The Essence of C++ [video]
by a8da6b0c91d on Tuesday September 17, 2013 @07:01PM
(#6402465)
The point is move makes things that look like values as annoying as pointers. You have to keep track.