Idea: Introduce zero-terminated string specifier

David Nadlinger see at klickverbot.at
Tue Oct 2 12:34:44 PDT 2012


On Tuesday, 2 October 2012 at 19:31:33 UTC, Steven Schveighoffer 
wrote:
> On Tue, 02 Oct 2012 15:17:42 -0400, David Nadlinger 
> <see at klickverbot.at> wrote:
>
>> On Tuesday, 2 October 2012 at 02:22:33 UTC, Steven 
>> Schveighoffer wrote:
>>> @system char[] zstr(char *s) { return s[0..strlen(s)]; }
>>>
>>> […]
>>>
>>> Does it make sense for Phobos to provide such a shortcut in 
>>> an obscure header somewhere?  Like std.cstring?  Or should we 
>>> just say "roll your own if you need it"?
>>
>> I didn't look it up, so I could be making quite a fool of 
>> myself right now, but doesn't to!string(char*) provide exactly 
>> that?
>
> string is immutable.  Must allocate.
>
> You fool :)

Well, make it to!char(char*) then! ;)

David


More information about the Digitalmars-d mailing list