Idea: Introduce zero-terminated string specifier

deadalnix deadalnix at gmail.com
Mon Oct 1 05:13:11 PDT 2012


Le 01/10/2012 13:29, Vladimir Panteleev a écrit :
> On Monday, 1 October 2012 at 10:56:36 UTC, deadalnix wrote:
>> Le 30/09/2012 21:58, Vladimir Panteleev a écrit :
>>> On Sunday, 30 September 2012 at 18:31:00 UTC, deadalnix wrote:
>>>> If you know that a string is 0 terminated, you can easily create a
>>>> slice from it as follow :
>>>>
>>>> char* myZeroTerminatedString;
>>>> char[] myZeroTerminatedString[0 .. strlen(myZeroTerminatedString)];
>>>>
>>>> It is clean and avoid to modify the stdlib in an unsafe way.
>>>
>>> That's what to!string already does.
>>
>> How does to!string know that the string is 0 terminated ?
>
> By convention (it doesn't).

It is unsafe as hell oO


More information about the Digitalmars-d mailing list