On Thursday, 27 February 2014 at 14:41:27 UTC, Dicebot wrote:
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
How can I then use it as a function return value? Or store in a
container?
Actually if postblit had a bool param saying that the source is
rvalue then moving would be possible by just resetting relevant
fields in source object.