(ref.doc)Wrap them wrascally arrays!

Prev: A const source of confusion Up: cppR 5/5

Wrap them wrascally arrays!
Best of comp.lang.c++
by James Adcock (Note:
 Adcock)

Book reference:
C++ Strategies and Tactics
by Rob Murray
Murray Hill, 1993

'new TYPE[0]' returns a ptr to the start of an array of zero TYPE
-which is zero in front of one past the end of the array.

sizeof(TYPE[0]) == 0 * sizeof(TYPE) == 0
for the theoretical size of the allocation.

"new TYPE[0]" would consume at least four bytes in practice. And if
the implementation uses an additional four-byte word to record the
allocation size, 'new TYPE[0]' consumes a total of eight bytes -for
nothing!


automatically generated by info2www version 1.2.2.8