On Monday, 20 April 2015 at 21:58:59 UTC, Ali Çehreli wrote:
On 04/20/2015 02:44 PM, Namespace wrote:
> Thank you. Do you mean this is worth a PR, to add this
> functionality to Phobos?
I am not familiar with such a need so I don't have a strong
opinion.
However, if an object needs to be emplaced on top of an
existing one, I can imagine that the original object was
emplaced on some piece of memory anyway. In that case, the
problem becomes "emplacing an object on a piece of memory",
which is already supported by std.conv.emplace.
Your idea seems to be for the case where the original object is
created by some third party code, and that they want us to
replace it with another object. If they are aware of the
wholesale change in the object, fine. :)
Ali
I have currently an array of objects which may be reloaded (it's
a tilemap). If the array is reused, I can do that with:
----
arr.length = 0;
arr.assumeSafeAppend();
----
But then I thought: why not reuse the memory of the objects?
In C++ you can do that very elegant, but in D I have to produce
garbage since the old object stays alive until the GC collects it
and I have to allocate new GC memory.