Allocate a string via the GC
JG
someone at somewhere.com
Mon May 23 12:20:11 UTC 2022
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.
I am writing an interpreter and I needed access to a string via
a pointer of type void*
I ended up wrapping it in a struct since I needed another value
anyway. Seems odd that one can't do it in a less unusual way.
Thanks.
More information about the Digitalmars-d-learn
mailing list