Allocating a wstring on the stack (no GC)?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun May 18 01:40:05 PDT 2014


On 5/7/2014 12:03 PM, Maxime Chevalier-Boisvert wrote:
>> auto ptr = cast(wchar*)alloca(wchar.sizeof * len);
>> if (ptr == null) throw new Error("...");
>> auto mySlice = ptr[0 .. len];
>
> Is the slice going to be allocated on the stack? (I imagine the answer is yes)

Yes (slices do not copy).



More information about the Digitalmars-d mailing list