Writeup for A-21, proposal C

Matt Austern austern at isolde.engr.sgi.com
Tue Feb 15 18:43:52 UTC 2000


PROPOSAL C

Like proposal B, except that we don't save an element count
if the type T has no destructor.

Pseudocode for new(ARGS) T[n] under this proposal:

    if T has a trivial destructor (C++ standard, 12.4/3)
      padding = 0
    else if we're using ::operator new[](size_t, void*)
      padding = 0
    else
      padding = max(sizeof(size_t), alignof(T))

    p = operator new[](n * sizeof(T) + padding, ARGS)
    p1 = (T*) (p + padding)

    if padding > 0
      *((unsigned long*) p1 - 1) = n

    for i = [0, n)
      create a T, using the default constructor, at p1[i]

    return p1




More information about the cxx-abi-dev mailing list