Idea: Introduce zero-terminated string specifier
Steven Schveighoffer
schveiguy at yahoo.com
Tue Oct 2 12:31:46 PDT 2012
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 :) just kidding, honest mistake.
-Steve
More information about the Digitalmars-d
mailing list