STL or Not?
Just a quicky...
Is there any accomplished game programmers who are using
any part, or all of the Standard Template Library in the
development of thier games?
If there is, then is there a noticible amount of performance
overhead compared to ''C Style Functions''?
ie using ''const char*'' compared to ''string''
Thanks in advance
Can''t claim to be an expert, since I only started using it recently but I will say I have yet to hear anything negative about it and I have enjoyed using it so far. I plan to continue to make a part of my current project.
Sieggy
Sieggy
A C string will always be faster than a STL string, simply because the string class does more things for the programmer. If you were to add the same functionality yourself, the STL string will probably be faster. However, all STL classes have been made with performance in mind.
Erik
Erik
Hmm, for the same operations I doubt you could be faster with a C-style string than an STL one... unless you''re just passing data to functions.
As soon as you need to do anything fancy with it ( finding stuff ) you''ll be hard-pressed to beat STL performance.
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
As soon as you need to do anything fancy with it ( finding stuff ) you''ll be hard-pressed to beat STL performance.
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
We use many parts of the STL in our game code, and even though I''m sure they are not as fast as if you coded each part to meet exactly your needs, I don''t any of us have the development time to do so and create a bug free, more efficient, way to do most of these things (even without the extra features you don''t need). Here are the parts we use:
fstreams, stringstreams, deque, map, string, pair, rel_ops, and sometimes vectors (prefer deque, we only use vector when insertion is rare, or all done at load time, but search is extremely common and important). I believe you will find that you pay mostly in size not speed when you use the STL, so if your executables are already in the megabytes, don''t fret, but if your trying to build a 150K DirectX program, avoid all C++ extras (not OOP though) - including templates, multiple inheiritance, RTTI, exceptions, and the IOStream library.
Good Luck!
fstreams, stringstreams, deque, map, string, pair, rel_ops, and sometimes vectors (prefer deque, we only use vector when insertion is rare, or all done at load time, but search is extremely common and important). I believe you will find that you pay mostly in size not speed when you use the STL, so if your executables are already in the megabytes, don''t fret, but if your trying to build a 150K DirectX program, avoid all C++ extras (not OOP though) - including templates, multiple inheiritance, RTTI, exceptions, and the IOStream library.
Good Luck!
Xai, you are right! STL does make your program bigger (but not that slow). Here''s my simple comparison:
168k with iostream vs 76k without
Another from STL that I found quite handy is auto_ptr. I still love STL.
One thing, my initials are S.T.L. too!!
168k with iostream vs 76k without
Another from STL that I found quite handy is auto_ptr. I still love STL.
One thing, my initials are S.T.L. too!!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement