Page 1 of 1
STL Benefits and Pitfalls
Posted: Wed Oct 08, 2003 9:20 am
by shamim
The use of STL has dramatically changed the way code in C++.
Unfortunately, we are receiving posts that reflect some pitfalls of STL.
I request everyone to share their bad experiences they had, in solving a problem using STL so that we all can be aware of it.
Although, I did not yet suffer, but I got poor timing in solving a problem, and i am sure it is due to using STL, because an alternate solution without STL, solved at a much less time.
Posted: Wed Oct 08, 2003 9:53 am
by Viktoras Jucikas
Technically, you should not get order of magnitude worse timing if using STL. There is nothing bad with STL, it just might be that you are not using it optimally (and there are millions of ways to abuse STL - but that's your problem, not STL).
Posted: Wed Oct 08, 2003 10:18 pm
by Per
Where is the alternative "I've had no problems with STL"?
There are at least two necessary conditions for STL code to be roughly as fast as (well written) "normal" code:
# The STL code is also well written.
# The STL code is compiled with some optimisation, so that methods like the []-operator for vector and many other get inlined. Sadly, this is often not the case in programming contest environments.
But as Viktoras said, you'll still only get a constant factor worse by using STL (as long as you're using it correctly).
And of course, just using cin/cout (not STL, but still a related issue) is extremely slow compared to scanf/printf, since by default, all iostream operations get synchronised with stdio. (Though it is possible to disable this synchronisation.)
Posted: Fri Oct 31, 2003 3:55 am
by Moni
"I had some other problem"
That's I am not well user of it!
And as said earlier... it's my problem, not STL...
Actually they are very good stuff.....done lots of advaced things with it
And you should practice them with GNU C++ compiler
By downloading from sgi..........that will reduce your RTEs.