Array::add() needs a return value


#1

It’s great that Array can take a template parameter for TypeOfCriticalSectionToUse but if multiple threads are calling add() how can you ever know which index you got? add() should look like this:

int add (ParameterType newElement)
{
    const ScopedLockType lock (getLock());
    data.ensureAllocatedSize (numUsed + 1);
    new (data.elements + numUsed++) ElementType (newElement);
    return numUsed;
}

Something similar will be needed for addIfNotAlreadyThere.

This goes for all array type containers.