GC for noobs

Dicebot public at dicebot.lv
Thu Feb 27 06:41:26 PST 2014


On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner 
wrote:
> They actually don't have all the necessary features in D afaiu. 
> They do have value semantics but can't represent uniqueness 
> because of missing move d-tor.
>
> For example in C++ I can create a function that returns a 
> Texture class instance and be sure that it is the only one when 
> receiving it (because copying is disabled). Then I can always 
> safely release all resources related to this texture in objects 
> d-tor. In D I can't use struct for this because I would get 
> double-free in d-tor so a class instance has to be used instead.

You can disable postblit to make entity non-copyable: 
http://dlang.org/struct.html#StructPostblit


More information about the Digitalmars-d-learn mailing list