How about some __initialize magic?
Per Nordlöw
per.nordlow at gmail.com
Mon Dec 13 23:18:13 UTC 2021
On Saturday, 27 November 2021 at 21:56:05 UTC, Stanislav Blinov
wrote:
> ```d
> T stuff = T(args); // or new T(args);
> ```
>
> but this?..
>
> ```d
> T* ptr = allocateForT();
> // now what?.. Can't just do *ptr = T(args) - that's an
> assignment, not initialization!
> // is T a struct? A union? A class? An int?.. Is it even a
> constructor call?..
What about taking inspiration from C++'s
https://en.cppreference.com/w/cpp/language/new#Placement_new
? Allocators could be supported by either
- passing the allocator as to `new()` as an the first normal or
template parameter or
- have `new` be defineable as a member function of an allocator
(or any struct or class)
?
More information about the Digitalmars-d
mailing list