Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kraiklyn

STL or Not?

This topic is 6911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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**

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!