News for hackers. Stuff that matters.
Re:Care is needed to use C++ std:optional with non-trivial o... by throway2kl4223 on Friday January 13, 2023 @09:59AM (#34368607)
It's an immediate red flag to see `T::T(T)` used anywhere for non-trivial objects or PODs or something not word-size.

Typically C++ requires a lot of plumbing to use value semantics with `std::move` everywhere and `std::forward`.

I don't have patience for it anymore, so I just use Rust which is move by default.

Re:Care is needed to use C++ std:optional with non-trivial o... by kllrnohj on Friday January 13, 2023 @10:55AM (#34369502)
A "move" of a POD value type is still a copy and std::move/std::forward don't do anything (same in Rust for Copy traits).

Rather the Rust feature that's missing here is the compiler automatically converting pass-by-(move)value to a pass-by-reference under the covers.