What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

ponce via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 9 16:22:47 PDT 2015


On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:
>
> This is subtly missing the main question: isn't C++-like memory 
> management of D classes possible with Unique, RefCounted and 
> Scoped?


- Unique

C++ has move semantics which make moves explicit. D's Unique is 
more like the deprecated C++'s auto_ptr: it has an opAssign 
overload that changes the owner.

- RefCounted

Only for D structs. std::shared_ptr works for all.





More information about the Digitalmars-d-learn mailing list