On Monday, 27 November 2017 at 07:09:25 UTC, Ola Fosheim Grostad
wrote:
But it kinda is missing the point that if it only is in a
single thread then it would typically only have only one
assignment. Shared_ptr is for holding a resource not for using
it...
Just to expand a bit on this: What is lost here is that what has
been proposed for D is to have a RC solution to solve what Rust
does with borrowed pointers. Not unlike Swift.
In C++ life time management of borrowed pointers is fully manual,
so it relies on algorithmic design rather than a programming
mechanism. Although for C++ there is upcoming wrapper-types to
allow for separate static analysis tooling that is comparable to
Rust.
The intended usage is not comparable. (In C++ you typically will
have per-type or per-application RC, wrapped up where you need it
by encapsulation and move-semantics.)