String view

Lionello Lunesu lionello at lunesu.remove.com
Sun Jan 21 12:28:00 PST 2007


char* p = ....;
char[] stringview = p[0..strlen(p)];
assert( stringview.ptr is p );

"NN" <nn-mail at bk.ru> wrote in message 
news:ep0ic7$1a9c$1 at digitaldaemon.com...
> Why there is no string view in D ?
>
> Assume I have pointer in memory pointing to zero ending string:
> char* p;
>
> I want to create a string from it but i do not want to copy it.
> Assume I have a special class for this:
> StringView s(p);
>
> But what would I do if function receives char[] ? There will be a copy.
> What if I do not want a copy ?
>
> Thanx. 





More information about the Digitalmars-d mailing list