UniquePtr in D

Sergei Nosov sergei.nosov at gmail.com
Sun Dec 22 22:57:55 PST 2013


On Sunday, 22 December 2013 at 13:40:30 UTC, Benjamin Thaut wrote:
> Uh, this looks a lot better then std.typecons.Unique
> Did you try doing a pull request to replace std.typecons.Unique 
> with your implementation?

No, I didn't.

I'm kind of thinking, that the "unique" concept currently can't
be fully implemented as a library solution. It needs at least
some language support - disallow refernce usage for safety, make
obvious implicit casts for... you know... for kids (currently,
when I use this implementation ".unique" and "Unique!T"
everywhere kind of clutters the code, and it also adds some
burden on writing generic (or just general) code). So, it's kind
of an open question.

> You probably want to fix this:

> class C{}

> void main(){
>    auto x = unique!C().pack;
>    auto y = x.unpack;
>    auto z = x.unpack;
>    assert(y.irel is z.irel);
>}

That's right! Thanks!




More information about the Digitalmars-d mailing list