Jump to content
  • Advertisement

Archived

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

Spartacus

Standard Template Library?

This topic is 6504 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

Hi... Can someone please tell me about STL and what i can use it for. Is it just a huge collection of frequently used stuff like vectors and strings? When i write std:: in VC++ 6 i see this BIIIG list of functions, templates, structs and variables. Then i take a look at std::string where every function has a minimum of 5 overloads, and everything just seems sooo complicated. Can someone maybe refer to a place on the net where i can find good documentation on STL? And would it be a good idea to use STL instead of writing everything myself as i use to do? Any help is greatly appreciated. -René Petersen

Share this post


Link to post
Share on other sites
Advertisement
As an avid STL user, I can give you some thoughts about which templates to focus on, at least in the beginning. There are a lot of STL templates, and not all of them are widely useful for games (or at least, i''ve been able to get along without them).

vector (resizeable array)
list (linked list)
basic_string (string type--yes, its compatible with C string functions)
map (exchanges values of one type into another type, like basic_string to a void*)

Share this post


Link to post
Share on other sites
While TANSTAAFL doesn''t need my approval, I will ring in and say that I''m in complete agreement with the advice he gave you. I''d suggest that you play with vectors or basic_string before you move on to anything else. Reason being, most books I''ve read and from what I can remember when learning C++ years ago, strings and arrays themselves are what you spent a lot of time playing around with example programs while you learned C++. It''s easy to comprehend what those containers are and what there doing and how operations work on them.

As with all blanket statments there are going to be exceptions here and there so with that in mind, if you know one container you know them all...

YAP-YFIO,
deadlinegrunt

Share this post


Link to post
Share on other sites
I''d have to add priority_queue to the list of must know containers in the STL. (If I see one more programmer implement heap operations on a vector....)

Of course the templated algorithms are just as useful as the templated containers. Ex: random_shuffle, accumulate, sort, inner_product, for_each, etc.

Also function objects are a lot more useful than they appear at first.

(Take this all with a grain of salt, I personally can''t stand the STL, but if you''re going to use it, use it right.)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!