Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
118 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

The C++ Standard Library Part 1
Language Features


Introduction

Much of the power and productivity of the C++ language comes from its standard library. However, the standard library is a fairly complicated collection of functions and classes, which can make it hard to use and hard to get the most out of. This article series aims to introduce basic usage and best practices for using the C++ standard library. As much as I will try to make each article only depend on the articles before hand, the standard library can be considered to be more or less an integrated whole, and as such I will be mentioning things that will be covered in later articles, and some things I will only partially cover and leave the details for later.

Also, I will not be covering parts of the C++ standard library that have been incorporated from the C standard library, such as the C file I/O functions or the math functions.

This first article focuses on some features of C++ important to the use of the standard library that may not familiar to beginning C++ programmers or programmers coming from another language like C. However, I will assume knowledge of the basic C++ language features like how to create and call functions, how to create classes, loops, if statements and using header files. [1] I also assume that you are familiar with the basics of using iostreams for input and output. Not necessarily anything fancy with iostreams, but the basics like using cout for output and fstreams to read numbers.

In this article I will be going over namespaces, templates and exceptions. The coverage of these topics in this article is not meant to be comprehensive. Templates, for instance, are complicated enough that an entire book can be dedicated towards them (and has). However, the coverage should be sufficient to use most of the features of the C++ standard library.

A Note About Standards

C++ is a constantly evolving language, so it's important to know what version a given article is talking about. The C++ language was originally created by Bjarne Stroustrup, and was released in a series of versions along with the compiler CFront. The C++ Standards committee was formed in 1989 and the first version of the standard was released in 1998 in the document ISO/IEC 14882:1998. In 2003, a technical corregenda was released in the form of the document ISO/IEC 14882:2003. This is an essentially an errata version, no major changes were introduced in 14882:2003, only clarifications and corrections. The standards committee is currently working on the next version of the standard, which is anticipated to be released in 2009 and will have major changes. In the meantime, the standard library committee is working on a series of additions to the library that are being released in a documents called technical reports. At this time, Technical Report 1 has been released, and Technical Report 2 is still in the process of accepting proposals.

This article series is being written at the beginning of 2006, and so covers the C++ Standard with Technical Corregenda 1 (document ISO/IEC 14882:2003), and the C++ Standard Library committee's Technical Report 1. At this point, recent compilers are almost all mostly in compliance with ISO/IEC 14882:2003, but almost none of Technical Report 1. [2] However, many of the library additions detailed in Technical Report 1 are implemented in the Boost C++ Library. So while Boost is not part of the C++ Standard Library, I will be referring to parts of Boost in this article series as they form the basis of parts of the Standard Library not implemented by current C++ compilers.





Namespaces


Contents
  Introduction
  Namespaces
  Templates
  Exceptions
  Closing and References

  Printable version
  Discuss this article

The Series
  Language Features
  std::vector