Aaron N. Tubbs bio photo

Aaron N. Tubbs

Dragon chaser.

Twitter Facebook Google+ LinkedIn Github

Microsoft has promised to update their documentation with the same advice, but until that point I wanted to get this out there: Never use anything but POD types with a CArray. This is due to the SetSize function being “poorly designed” (direct quote, read the code and you will agree; it does things in a way ignorant of C++, for the sake of speed) within said container. The official recommendation is to use std::vector to store anything other than POD types, which is a great idea for non-legacy code.

For great justice, try storing something inside of a CArray with a checked iterator implementation in VC2008, grow the container (either implicitly via append or explicitly via setting size), and then attempt to create an iterator from the items already in the container in release mode.