Re: D structs weak identity and RAII

2017-06-19 Thread Boris-Barboris via Digitalmars-d-learn
On Monday, 19 June 2017 at 06:34:49 UTC, Ali Çehreli wrote: It's unreliable because structs are value types in D, which means that they can be moved around freely. This is why self-referencing structs are illegal in D. I guess it's more like the spec states, that they can be moved vithout not

Re: D structs weak identity and RAII

2017-06-18 Thread Ali Çehreli via Digitalmars-d-learn
On 06/18/2017 06:22 PM, Boris-Barboris wrote: > https://dpaste.dzfl.pl/d77c72198095 > > 1). line 47 and 76 together mean, that there is basically no reliable > way to write uniqueptr method wich returns WeakPointer, registered by > the correct pointer in it's constructor. Or is there? Is usage of

D structs weak identity and RAII

2017-06-18 Thread Boris-Barboris via Digitalmars-d-learn
Hello, I was trying to write some templated unique pointers. Idea was simple: struct UniquePointer that handles underlying pointer in RAII-style and WeakPointer struct that is spawned by UniquePointer. Weak pointer is handled differently in my collections, wich subscribe to the event of UniqueP