Thread overview | |||||
---|---|---|---|---|---|
|
September 16, 2013 Emplacement in D | ||||
---|---|---|---|---|
| ||||
After having read about http://dlang.org/phobos/std_conv.html#.emplace I wonder: Considering the fact that D has stricter control over memory, couldn't the need for emplace be removed through clever D compiler optimization when for example adding structs at the end of an array and assuming its constructor is safe? At least If all the members recursively have value semantics it would be obvious right? But maybe that is a corner case. |
September 17, 2013 Re: Emplacement in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | On Monday, 16 September 2013 at 21:35:24 UTC, Nordlöw wrote:
> After having read about http://dlang.org/phobos/std_conv.html#.emplace
>
> I wonder: Considering the fact that D has stricter control over memory, couldn't the need for emplace be removed through clever D compiler optimization when for example adding structs at the end of an array and assuming its constructor is safe?
>
> At least If all the members recursively have value semantics it would be obvious right? But maybe that is a corner case.
Emplace is designed for user control, when the user wants to "emplace" an object over already allocated memory. It's basically just for user managed memory.
Appending to an array *is* managed by the compiler (well, druntime to be exact), via postblit. EG: memcpy followed by postblit.
That said, druntime does this completly... "runtime", so isn't as optimal as it could be, but it's something we are working on.
|
September 17, 2013 Re: Emplacement in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | Nice! Thx, Per |
Copyright © 1999-2021 by the D Language Foundation