I've spotted a bug in IwArray (seen in 5.1.3 with no mentions in the changelog for newer versions). The constructor accepting a size doesn't result in a container of that size, e.g.:
{syntaxhighlighter brush:cpp;collapse:false}CIwArray As you'll see the vector has 10 entries but the IwArray doesn't. Looking into the array's constructor the entries are created (in push_back_qty()) but clear() is called immediately afterwards (destroying the newly created elements).
cout
vector
cout












CIwArray a;
a.push_back_qty(10);
would be what your looking for.
But yes that is confusing, the constructor states that it takes a size
"@param sz If specified initialise the array with sz newly constructed members."
but what it really does is only reserving capacity for at least that many elements..
It's clearly a bug. It doesn't just reserve, it reserves, performs a placement new, then calls the destructor. If it's not a bug then the implementation neither follows the documentation nor is it an implementation of vector.
I agree with PetterL, it's confusing that the documentation says "...newly constructed members" when the members are actually NOT constructed. I guess "newly destructed" would be correct, but that's also confusing.
I don't agree with CW, though; this is NOT a bug, it's just a difference between CIwArray and std::vector. The purpose of the CIwArray constructor is to allow the user to allocate the appropriate amount of memory in the constructor, but NOT have constructed objects.
I also DO agree with CW: CIwArray isn't an implementation of std::vector. It's an implementation of CIwArray.