digitalmars.D - Emplacement in D
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (8/8) Sep 16 2013 After having read about
- monarch_dodra (9/17) Sep 16 2013 Emplace is designed for user control, when the user wants to
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (3/3) Sep 17 2013 Nice!
After having read about 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.
Sep 16 2013
On Monday, 16 September 2013 at 21:35:24 UTC, Nordlöw wrote:After having read about 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.
Sep 16 2013