Unofficial Hacker News client - receive Push Notifications on replies.

In C++, = default and {} are not the same constructor (opens external site)

131 points by surprisetalk 5 days ago | lemire.me | 199 comments on HN | Vote on HN (opens Hacker News)

View full thread · View on Hacker News

Comment thread (1)

  1. Excellent explanation, thanks. Rust’s move semantics around “all types must survive a memcpy” are (IMO) a great idea 99.9% of the time (no move constructors, no worrying about “pillaging” the source of a move to make its destructor safe to run, you can express more invariants since you don’t need to be able to express such pillaging) but it’s one of the places where something that is “simple” in C++ is truly hard to accomplish in Rust.

    Rust has added Pin later on in the language to express data that can’t be moved, but IME I only see it used in desugared async code to guarantee that values stay put between awaits, and it’s not common to see Pin used for general code. I don't think you can just sprinkle some Pin<T> into existing code and solve the object identity problem, although I've never really had to deal with code that's move-sensitive so I don't know.