digitalmars.D.learn - DIP1000 & Owning Containers
- jmh530 (16/16) Jan 08 2018 DIP1000 has a section on owning containers where it shows that
DIP1000 has a section on owning containers where it shows that you can have a reference to a member of a struct that will not outlive the struct itself. This seems to work through the function opAssign being scope ref. Why wouldn't you normally be allowed to make a scoped pointer to a member of a struct? By contrast, it says near the top that you can use scope to annotate non-static member functions and delegates, which would be other examples of interior pointers, but no mention of members. Also, I don't really have a good sense of how DIP1000 will be implemented. If I got a reference to payload in that Owned Containers section, then surely the compiler would know what that some instance of RefCountedSlice is the owner, at least at compile-time. Would it be possible to have a trait that is like getOwner(payload) and maybe have it return a string for the name of the instance?
Jan 08 2018