Allocate a string via the GC

bauss jj_1337 at live.dk
Mon May 23 12:18:43 UTC 2022


On Monday, 23 May 2022 at 12:17:56 UTC, bauss wrote:
> On Monday, 23 May 2022 at 11:39:22 UTC, Adam D Ruppe wrote:
>> On Monday, 23 May 2022 at 09:38:07 UTC, JG wrote:
>>> Hi,
>>>
>>> Is there any more standard way to achieve something to the 
>>> effect of:
>>>
>>> ```d
>>>   import std.experimental.allocator;
>>>   string* name = theAllocator.make!string;
>>>  ```
>>
>> Why do you want that?
>>
>> Easiest way I know of is to just wrap it in a struct, then 
>> `new that_struct`, which is also a better way for all the use 
>> cases I know.... but those use cases are pretty rare so 
>> there's probably a better way to do what you're trying to do.
>
> My guess is @nogc in which case your solution doesn't work.
>
> Same with Ferhat's examples.

Oops wait, I just saw that it says "via the GC" in the title. I 
completely missed that until I had of course sent my other 
message.


More information about the Digitalmars-d-learn mailing list