Re: disadvantages of using STL
On Mar 30, 6:17 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
zr wrote:
On Mar 17, 10:31 pm, Pallav singh <singh.pal...@gmail.com> wrote:
Q What are the disadvantages of using STL ?
Since no one mentioned it, what about code bloat? Is this still an
issue in recent implementations?
It's never been a problem for me.
It probably depends on what you're doing. The STL, in general,
has been designed to favor speed when it comes to speed/space
trade offs, and so is probably inappropriate in contexts where
space is extremely restricted. Which doesn't motivate
implementors to reduce the size of the executable.
More generally, however... If you look at the source code for
the STL, you'll find that underneith it all, it's very simple.
There just isn't that much of it. So if you get two copies of
the code when you instantiate two different types (even though
most of it is identical), the code you write using the instances
(which isn't identical) is usually so much bigger that it
doesn't matter.
If you do find that your performance is suffering because of
unnecessary icache misses, there are straight-forward
techniques to address the problem. (I've heard the old
technique of partially specializing for all raw pointer types,
then wrapping a non-template implementation that only uses
void*, referred to as "hoisting.")
So you gain 40 or 50 bytes of code if you instantiate the class
over two different pointer types, but you still have maybe 100KB
of user code using each instantiation.
--
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