This section of the archives stores flipcode's complete Developer Toolbox collection,
featuring a variety of mini-articles and source code contributions from our readers.

Bloat-free Typed Pointer Vector Class
Submitted by

I'm not sure how many people already have this kind of thing going, but if not, it's never too late.
I hate bloat in my code, and so I often used to use vector< void* > to store lists of objects.
However, this adds the encumbrance of having to type cast whenever you want to use the object.
Every vector< myobject* > can add about 1k of code to your app (my findings).
I was initially going to do this with template specializations, but shortly after I learned about that I learned that VS.NET 7 doesn't have support for it. Anyway- It wasn't much work to rewrite most of the vector class. It's not exactly like <vector> but it should be similar enough that you can plug it right in and it should work with most of your code. One thing that will need fixing is the erase() function, which takes numeric indices instead of references to begin() and end().
I'm not 100% sure if it's bug free, but I use it throughout over 100k lines of code, and I know of none.
This software is free for any use.
You can contact me rogajin@hotmail.com