I wonder if the language could be updated so these extra std::move invocations actually become harmless? return std::move is something that I see used quite a bit.
@QuadriLiteral@lysdexic We’ve been looking at a paper just recently in Kona, where the author proposed to not penalize “unfortunate” uses of std::move. I think this is user friendly and you might imagine what I’ve been voting for.
I wonder if the language could be updated so these extra std::move invocations actually become harmless? return std::move is something that I see used quite a bit.
These std::move invocations are harmless, as they only cast objects to their rvalue reference.
The destructive bit takes place in the type they are assigned to, as it invokes either a move constructor or a move assignment operator, and calling those implies that the object you just passed to std::move will be invalidated after the call and should not be used subsequently.
I wonder if the language could be updated so these extra std::move invocations actually become harmless? return std::move is something that I see used quite a bit.
@QuadriLiteral @lysdexic We’ve been looking at a paper just recently in Kona, where the author proposed to not penalize “unfortunate” uses of std::move. I think this is user friendly and you might imagine what I’ve been voting for.
That sounds great!
These
std::move
invocations are harmless, as they only cast objects to their rvalue reference.The destructive bit takes place in the type they are assigned to, as it invokes either a move constructor or a move assignment operator, and calling those implies that the object you just passed to
std::move
will be invalidated after the call and should not be used subsequently.I mean harmless in a way that using std::move on the return type doesn’t prevent RVO?