C++ std::move doesn't move anything: A deep dive into Value Categories
1–10 of 220 posts
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#2> std::move is like putting a sign on your object “I’m done with this, you can take its stuff.”
Which exactly is moving ownership.
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#3I always understood move as moving ownership, so it's not a misnomer. > std::move is like putting a sign on your object “I’m done with this, you can take its stuff.” Which exactly is moving ownership.
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#4I always understood move as moving ownership, so it's not a misnomer. > std::move is like putting a sign on your object “I’m done with this, you can take its stuff.” Which exactly is moving ownership.
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#5Rust’s borrow checker doesn’t actually borrow anything either, it’s operating on a similar level of abstraction.
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#6I always understood move as moving ownership, so it's not a misnomer. > std::move is like putting a sign on your object “I’m done with this, you can take its stuff.” Which exactly is moving ownership.
Std move doesn’t move ownership. It simply casts into something that could have its ownership taken. Whether or not that actually happens is impossible to identify statically and the value after ownership is consumed is unspecified - sometimes it’s UB to access the value again, sometimes it’s not.
Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#7Re: C++ std::move doesn't move anything: A deep dive into Value Categories
#8I always understood move as moving ownership, so it's not a misnomer. > std::move is like putting a sign on your object “I’m done with this, you can take its stuff.” Which exactly is moving ownership.
Std move doesn’t move ownership. It simply casts into something that could have its ownership taken. Whether or not that actually happens is impossible to identify statically and the value after ownership is consumed is unspecified - sometimes it’s UB to access the value again, sometimes it’s not.
It needs to remain destructible, and if the type satisfies things like (move-)assignable/copyable, those still need to work as well.
For boxed types, it's likely to set them into some null state, in which case dereferencing them might be ill-formed, but it's a state that is valid for those types anyway.