Re: disadvantages of using STL
On Mar 19, 7:50 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
Juha Nieminen wrote:
Jeff Schwab wrote:
I don't see how. The STL does not even require its
elements to have member functions, much less virtual member
functions.
Oh, you mean the intrusive data containers are not template
classes but regular ones, and resort to use virtual
functions on the members?
Yes.
I thought intrusive data containers were supposed to be more
efficient than STL data containers.
They probably can be; the ones I've used just aren't.
I suspect that when you speak of "intrusive" containers, you
really mean non templated containers, where every member must
derive from some common base class (often Object). Generally
speaking, if you provide full value semantics, like the STL,
they will be less efficient. If you provide reference semantics
(as is usually the case), they will be as efficient as an STL
container of pointers, perhaps even slightly more so (although I
really doubt it).
In practice, this business of requiring everything to derive
from Object, and then having containers of Object*, is an idea
which has more or less been recognized as wrong. Jave started
this way, but has since added a limited form of templates to
avoid it. It fits in languages which don't do static type
checking, but that's not the case of C++ (nor Java)."
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34