HP aC++/HP C A.06.20 Programmer's Guide

For -AP Standard Library
The inline template function__rw_allocation_size can be explicitly specialized
to return the number of units for each type’s use in any container:
template <>
inline size_t __rw-allocation_size(bar*,size_t) {
return 1;
}
This would initially allocate one unit when dealing with containers of type bar.
Alternatively, if RWSTD_STRICT_ANSI is not defined, then container member
functionallocation_size can be used to directly set buffer_size, the number of
units to allocate.
For -AA Standard Library
The following 4 defines can change the container initial allocation and growth ratio:
For an arbitrary container type:
# define _RWSTD_MINIMUM_NEW_CAPACITY size_t(32)
# define _RWSTD_NEW_CAPACITY_RATIO float(1.618)
For a string type:
# define _RWSTD_MINIMUM_STRING_CAPACITY size_t(128)
# define _RWSTD_STRING_CAPACITY_RATIO float(1.618)
For more precise control of containers, the following explicit specialization can be used.
The namespace scope functiontemplate __rw can be explicitly specialized to return
the current size in elements of any container.
template <>
inline size_t __rw_new_capacity (size_t __size, const _Container*)
The parameters passed in are the current size in elements and the container's pointer.
The default behavior results in an amortized constant time algorithm that dramatically
increases rapidity while retaining a regard for space efficiency.
The defaults have been tuned with speed versus space optimization of container
performance with regard to allocation of memory.
The ratio parameter must be above 1 for an amortized constant time algorithm. Lowering
the ratio will lower rapidity and improve space efficiency. This effect will be most
noticable when working with containers of few elements (less than 32).
The following is a container allocation example for both the -AP and -AA Standard
library:
#include
namespace std {} using namespace std;
#include
#include
#define NUM 4
int printMallocInfo(const char*);
240 Tools and Libraries