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

Daniel Kozák via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 10 05:34:45 PDT 2015


On Thu, 10 Sep 2015 11:38:35 +0000
"Gary Willoughby" <dev at nomad.so> wrote:

> On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote:
> > - RefCounted
> >
> > Only for D structs. std::shared_ptr works for all.
> 
> RefCounted works with classes as well.
> 
> http://dlang.org/phobos/std_typecons.html#.RefCounted

struct RefCounted(T, RefCountedAutoInitialize autoInit =
RefCountedAutoInitialize.yes) if (!is(T == class) && !is(T ==
interface));

if (!is(T == class) && !is(T ==interface)); // So it does not work
with classes


More information about the Digitalmars-d-learn mailing list