Take the 2-minute tour ×

I've been programming c++ for about a year now and when i'm looking about i see lots of references to STL.

Can some one please tell me what it does?

and the advantages and disadvantageous of it?

also what does it give me over the borlands VCL or MFC?


share|improve this question
Chances are high you have been programming C for a year now and just discover C++. Seriously, C++ without STL is crippled. –  Thorsten79 Mar 25 '10 at 13:46
@Thorsten79: Or, if he genuinely doesn't know what the STL is, he may be using container classes, algorithms, and iterators as part of the standard library. The STL proper was a template library developed shortly before C++ was standardized, and it was simply absorbed into the standard library. –  David Thornley Mar 25 '10 at 13:51
@Jonathan D, VCL and MFC are mostly GUI frameworks. STL is a collection of data structures. –  Nick Dandoulakis Mar 25 '10 at 13:54
@Nick D: I wouldn't call MFC a framework :-) –  Rüdiger Stevens Mar 25 '10 at 14:00
@Nick D and algorithms, don't forget the algorithms –  jk. Mar 25 '10 at 14:14
show 2 more comments

9 Answers

up vote 23 down vote accepted

It's the C++ standard library that gives you all sorts of very useful containers, strings, algorithms to manipulate them with etc.

The term 'STL' is outdated IMHO, what used to be the STL has become a large part of the standard library for C++.

If you are doing any serious C++ development, you will need to be familiar with this library and preferably the boost library. If you are not using it already, you're probably working at the wrong level of abstraction or you're constraining yourself to a small-ish subset of C++.

share|improve this answer
what does it give me over borland VCL or microsoft MFC? –  Jonathan D Mar 25 '10 at 13:58
@Jonathan D: Portability, of the code you write and also yourself and your skills. –  Teddy Mar 25 '10 at 14:04
Jonathan D: The ability to get a C++ job. Claiming to know C++ without the ability to use the STL is going to get yuo rejected at the first level of any job interview. –  Loki Astari Mar 25 '10 at 14:07
Also, a lot of the other important C++ libraries like Boost do expect and use standard c++ containers semantics. If you're not familiar with the idioms, they feel strange to use whereas it will feel natural people who are familiar with the standard C++ library. Also, MFC is a particularly bad example of a C++ library, mainly due to its need for backward compatibility. Please do not try to learn good C++ library design from MFC. –  Timo Geusch Mar 25 '10 at 14:09
Jonathan D: While MFC has some string and container classes, it's secondary to the GUI elements. The STL (or, more accurately, the container classes, iterators, and algorithms) is completely unconcerned with the GUI, but gives you very powerful tools to organize and process data. I know nothing of VCL, but the MFC and STL are two very different libraries that do mostly different things. –  David Thornley Mar 25 '10 at 14:30
add comment

STL stands for Standard Template Library. This was a library designed mainly by Stepanov and Lee which was then adopted as part of the C++ Standard Library. The term is gradually becoming meaningless, but covers these parts of the Standard Library:

  • containers (vectors, maps etc.)
  • iterators
  • algorithms

If you call yourself a C++ programmer, you should be familiar with all of these concepts, and the Standard Library implementation of them.

share|improve this answer
Rumor has it STL actually stands for "Stepanov and Lee!" (Rumor had it, anyway...) –  John Dibling Mar 25 '10 at 14:10
add comment

The STL is the Standard Template Library. Like any library it's a collection of code that makes your life easier by providing well tested, robust code for you to re-use.

  1. Need a collection (map, list, vector, etc) they're in the STL
  2. Need to operate on a collection (for_each, copy, transform, etc,) they're in the STL
  3. Need to do I/O, there's classes for that.


1, You don't have to re-implement standard containers (cus you'll get it wrong anyway)

Read this book by Nicolai M.Josuttis to learn more about the STL, it's the best STL reference book out there.

share|improve this answer
add comment

It provides common useful tools for the programmer! Iterators, algorithms, etc. Why re-invent the wheel?

share|improve this answer
add comment

"advantages and disadvantageous" compared to what? To writing all that code yourself? Is not it obvious? It has great collections and tools to work with them

share|improve this answer
add comment

Wikipedia has a good overview: http://en.wikipedia.org/wiki/Standard_Template_Library

The STL fixes one big deficiency of C++ - the lack of a standard string type. This has cause innumerable headaches as there have been thousands of string implementations that don't work well together.

share|improve this answer
The string type in the Standard Library was never part of the STL, or at least of the STL designed by Stepanov and Lee. –  anon Mar 25 '10 at 13:46
@Neil You're right. It is part of the C++ Standard Library (en.wikipedia.org/wiki/C%2B%2B_standard_library), not the STL (en.wikipedia.org/wiki/Standard_Template_Library). but then I think many people say "the STL" when they mean "the C++ Standard Library". (The fact that they are many doesn't make them right, of course.) –  Daniel Daranas Mar 25 '10 at 14:00
Even so, you still find a lot of string libraries in C++ code. Remember RogueWave, CString + everyone used to think they could do it better? Not to mention that the reference counting in std::string wasn't thread-safe in a lot of implementations. –  Lou Franco Mar 25 '10 at 19:15
add comment

It stands for standard template library

It is a set of functions and class that are there to save you a lot of work.

They are designed to use templates, which is where you define a function, but with out defining what data type it will work on.

for example, vector more or less lets you have dynamic arrays. when you create an instance of it, you say what type you want it to work for. This can even be your own data type (class).

Its a hard thing to think about, but it is hugely powerful and can save you loads of time.

Get reading up on it now! You want regret it.

share|improve this answer
add comment

It gives you another acronym to toss around at cocktail parties.

Seriously, check the intro docs starting e.g. with the Wikipedia article on STL.

share|improve this answer
Programmers don't go to cocktail parties. They go to LAN parties. –  John Dibling Mar 25 '10 at 14:11
add comment

The STL has Iterators. Sure, collections and stuff are useful, but the power iterators is gigantic, and, in my humble opinion, makes the rest pale in comparison.

share|improve this answer
add comment

Your Answer


