News for hackers. Stuff that matters.
Re:Smart pointers and move semantics in modern C++ by Animats on Monday September 26, 2016 @12:32AM (#12579250)
Move semantics are a good idea, but C++ doesn't have the compiler machinery to catch when you move something away and then try to reference it. Move semantics really need a borrow checker, like Rust. In C++, you have to be very, very careful not to do things like accidentally move something passed to you as a non-const ref.
Re:Smart pointers and move semantics in modern C++ by int_19h on Monday September 26, 2016 @04:35AM (#12580210)
In C++, you can't "accidentally" move something that's a non-const ref, since a move from one would require explicit use of std::move.

The only things which can be moved accidentally are rvalues and rvalue references. But for rvalues, that doesn't hurt anything; and for rvalue references, the only reason why you'd use one is if you intended to play tricks with move semantics, which implies that you know what you're doing.

Basically if you write C++ as if move semantics didn't exist (i.e. never use rvalue references or std::move), you won't shoot yourself in the foot by those means. Of course, this also means that compiler assumptions are fairly pessimistic, so many places that could be a move aren't, because the move has to be explicit.

Re:Smart pointers and move semantics in modern C++ by jguegant on Monday September 26, 2016 @01:50AM (#12579511)