Historical Note

This page was migrated from the original p-nand-q.com site which was last updated in 2015. The content has been preserved exactly as it was, with only formatting updated for modern browsers. Over the coming days and weeks, the content will be reviewed and may be updated for accuracy and relevance. If you find any issues, please contact me.

Understanding the STL

Let's admit it: I am an old fool.

I started C++ in 1990, back when CFront was state of the art - but soon learnt as a young man that templates are something better to be avoided. I tried them when they were the new kids on the block, and ran into horrible code sizes (this was in a period of time when computers had RAM measured in KBytes) and error messages to boggle the mind. Plus, being an old assembler hacker, I loved macros, and who would be stupid enough to give up on macros for completely unreliable inline (back then typically ignored by compilers) code with a crippled feature set? No sir, I am not a masochist!

Old habits die hard, so fast forward 20 years to 2010 and there I was, am still not using any templates, or STL, or horrible nightmares like boost.

But with all the excitement about C++11 (and 14, and 17), last year I started reading books on C++ again (a little bit late, I admit), and in my old age have come to see templates a little bit more relaxed. And then... I was unfortunate enough to look into the STL to find out what was going on in a particular case, and found myself in good company: questioning the readability of the STL code. So I decided to waste my time and start a line-by-line discussion of the STL code, to see how much I can understand about it.

So now about the fool part of I am an old fool. Since I didn't know where to start, I decided to start with std::pair, because seriously, what could be more simple than that? And, to boot, I used the Microsoft implementation (in particular the one from Visual Studio 2013), because that is the compiler I use at work. Without further ado: