DMD 0.177 release
Chris Miller
chris at dprogramming.com
Sat Dec 9 09:00:26 PST 2006
On Sat, 09 Dec 2006 11:53:07 -0500, Alexander Panek
<a.panek at brainsware.org> wrote:
> Those are newCharz and newChars, of course.
>
> Apart from that, this might be interesting, too:
>
> // alias thingie array;
>
> template Ptr (T) {
> // Create a simple thingie
> T *newPtrs ( size_t size ) {
> return (new T[size]).ptr;
> }
>
> // Create null-terminated thingie
> T *newPtrz ( size_t size ) {
> T *p = (new T[size + 1]).ptr
> p[$ - 1] = '\0';
>
> return p;
> }
> }
>
> alias Ptr!(char).newPtrs newChars;
> alias Ptr!(char).newPtrz newCharz;
>
> Not tested, but this might be useful for someone.
>
Not bad, perhaps needs better names though. newChars still sounds like new
char[] (array). Maybe allocptr/ptrAlloc/ptralloc/palloc to have a similar
name as malloc since they have similarities (working with pointers).
*shrug*
More information about the Digitalmars-d-announce
mailing list