🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

STL library

Started by
5 comments, last by GameDev.net 24 years, 6 months ago
STL, (Standard Template Library) is a collection of handy tools for the C++ programmer. Resizeable vectors, maps, and a string class are all included, plus code that quicksorts, randomizes, etc.

You can learn more about it by purchasing the book _STL Tutorial and Reference Guide_, by David R Musser and Atul Saini, or by doing a search for STL in your MSDN docs.

It is supposedly standard and cross-platform, tho I've only played around with the VC++ version of it.

Mason McCuskey
Spin Studios
www.spin-studios.com

Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
Advertisement
The Standard Template Library is part of the C++ language (it was adopted formally in 1998). It is incredibly useful, providing object-oriented implementations of data structures like strings, dynamic arrays, linked lists, and maps, algorithms such as searching, sorting, counting, etc. Everything is in template form so you can use the STL for any data types. You can use it in Windows and DirectX as long as you are using C++, it won't work with C.

Before you learn STL, you should have a good understanding of templates; otherwise the notation can get pretty confusing. Check out this site for some online tutorials, or (and this is what I'd recommend), pick up C++: The Complete Reference by Herb Schildt. It has excellent coverage of pretty much everything in C++, including STL.

How about that Thinking in C++ 2nd Edition. It says it covers STL and is in PDF format. I don't have any links to it on hand, though
joeG
STL is where it's at.

One of those stupid things that us programmers do, no matter how much we try to go with code reuse, or use good object oriented, is create a linked list(or stack or something) from scratch every time we need it-

class x{
x* prev;
x* next;

...
}


class y{
y* prev;
y* next;
}

and sure it's not a big deal, but that's how errors or memory leaks sneak in. STL lets you use code for this kind of stuff thats been tested, tested, tested and isn't buggy.

On another post the question just came up again "How do you tell if a linked list loops?" With STL the answer is, it doesn't. With STL you don't have to worry about dereferencing a bad pointer or trying to dereference a NULL one at run-time.

I've had trouble with other compilers (ming) where STL made the executable jump up by 150kb (when it was only 100kb to begin with) but this shouldn't be a problem with MSVC.

(Yes, it's probably a little slower than rolling your own lists, but that's not why you use OO techniques)

-the logistical one-http://members.bellatlantic.net/~olsongt
A great online reference for STL is at http://www.sgi.com/Technology/STL/index.html .
Some of the posted notes I've read lately say something about an
STL library. I would like to know more information about it, so where
should I start? Is it difficult to use in a C or C++ program? I would
like to use it with MSVC++, Windows, and DirectX.

Zack

While I'm a new convert to using STL for many of the "drudge" chores associated with most types of C development, and heartily recommend it, I thought it might be worth noting that the STL isn't necessarily a speed demon. What specifically comes to mind is a comment in _C++ from the Ground Up_ that basically says the vector type is not as efficient as a straight up array. Does it matter? I'm not sure. For whatever speed is sacrificed, the STL does provide alot of power.

This topic is closed to new replies.

Advertisement