+/* make sure that the array has at least count elements */ \
+void name::SetCount(size_t count, T defval) \
+{ \
+ if ( m_nSize < count ) \
+ { \
+ /* need to realloc memory: don't overallocate it here as if */ \
+ /* SetCount() is called, it probably means that the caller */ \
+ /* knows in advance how many elements there will be in the */ \
+ /* array and so it won't be necessary to realloc it later */ \
+ if ( !Realloc(count) ) \
+ { \
+ /* out of memory -- what can we do? */ \
+ return; \
+ } \
+ } \
+ \
+ /* add new elements if we extend the array */ \
+ while ( m_nCount < count ) \
+ { \
+ m_pItems[m_nCount++] = defval; \
+ } \
+} \
+ \