3 ms·
> But even more than that, references that don't extend the lifetimes of objects (like native pointers and references) are simple to create and are in many ways
by catnaroek 10y ago
> But even more than that, references that don't extend the lifetimes of objects (like native pointers and references) are simple to create and are in many ways the default type of reference in C++.
There's nothing wrong with references that don't extend the lifetime of objects per se. Rust gets it right: the compiler checks that non-owning references don't outlive what they refer to.
> At any rate, 'this message queue only works with types that are easy to copy' is not generally a prominent part of the documentation in C++, if it's present at all.
I would expect it to be in the documentation. It could be phrased as follows: “This message queue only works with types with trivial copy constructors both for them and the types of their member variables, transitively”. Again, Rust gets it right: a generic can be parameterized by a type implementing the `Copy` trait. `MsgQueue<T: Copy>` tells you, in less than 20 characters, the same information as the preceding English tl;dr.