In article <Ru*****************@news01.bloor.is.net.cable.rog ers.com>,
Salvador I. Ducros <sd*****@rogers.com> wrote:
| "Andrew Koenig" <ar*@acm.org> wrote in message
| news:yu**************@tinker.research.att.com...
| > Salvador> I was hoping someone might be able to point me in the right
| > Salvador> direction. I'm currently using std::vector to maintain
| > Salvador> several lists whose objects are of unrelated types
| > Salvador> (classes). I've seen mentioned here and there a technique
| > Salvador> that uses 'void *' and something called 'template
| > Salvador> specialization' that would reduce the amount of code
| > Salvador> generated for the std::vector's.
| >
| > I guess the first question to ask is this: Is the amount of code
| > in question a serious problem?
| >
| > --
| > Andrew Koenig,
ar*@acm.org
|
| No. Not a problem. I simply wanted to educate myself about ways to avoid
| code bloat when using STL (& templates in general) for if and when it ever
| becomes a problem.
|
| On the other hand, I do find the amount of code being generated a bit much.
| I was able to reduce the code size significantly by using a generic
| container
| implemented in plain C. I'd rather use STL which is why I started searching
| for ways of reducing code bloat when using STL (std::vector in this specific
| case).
Bjarne Stroustrup's excellent text: The C++ Programming Language"
devotes a small section to this technique. The Metrowerks
implementation goes beyond the "void* optimization" and implements this
code size optimization across all pods (e.g. unsigned short and short
also share the same code).
--
Howard Hinnant
Metrowerks