The Standard C++ Library

The Standard C++ Library

The 1998 C++ standard consists of two parts: the core language and the C++ standard library; the latter includes most of the Standard Template Library and a slightly modified version of the C standard library. Many C++ libraries exist which are not part of the standard, such as the Boost library. Also, non-standard libraries written in C can generally be used by C++ programs.

The Standard C++ Library

The C++ standard library incorporates the C standard library with some small modifications to make it work better with the C++ language. Another large part of the C++ library is based on the Standard Template Library (STL). The names are formed by removing the “.h” extension and adding a ‘c’ at the beginning. For instance, ‘time.h’ transforms into ‘ctime’.

This provides such useful tools as C++ containers (for example vectors and lists), iterators (generalized pointers) to provide these containers with array-like access and algorithms to perform operations such as searching and sorting. Furthermore (multi)maps (associative arrays) and (multi)sets are provided, all of which export compatible interfaces. Therefore it is possible, using templates, to write generic algorithms that work with any container or on any sequence defined by iterators. As in C, the features of the library are accessed by using the #include directive to include a standard header. C++ provides sixty-nine standard headers, of which nineteen are deprecated.

Using the standard library–for example, using std::vector or std::string instead of a C-style array–can help lead to safer and more scalable software.

The STL (Standard Template Library) was originally a third-party library from HP and later SGI, before its incorporation into the C++ standard. The standard does not refer to it as “STL”, as it is merely a part of the standard library, but many people still use that term to distinguish it from the rest of the library (input/output streams [known as IOstreams], internationalization, diagnostics, the C library subset, etc.).

Most C++ compilers provide an implementation of the C++ standard library, including the STL. Compiler-independent implementations of the STL, such as STLPort, also exist. Other projects also produce various custom implementations of the C++ standard library and the STL with various design goals.

Taken from Free Encyclopedia:


One of the biggest time-wasters in C is using character arrays for string processing: keeping track of the difference between static quoted strings and arrays created on the stack and the heap, and the fact that sometimes you’re passing around a char* and sometimes you must copy the whole array.
Especially because string manipulation is so common, character arrays are a great source of misunderstandings and bugs. Despite this, creating string classes remained a common exercise for beginning C++ programmers for many years. The Standard C++ library string class solves the problem of character array manipulation once and for all, keeping track of memory even during assignments and copy-constructions. You simply don’t need to think about it.

Handling text is perhaps one of the oldest of all programming applications, so its not surprising that the C++ string draws heavily on the ideas and terminology that have long been used for this purpose in C and other languages. As you begin to acquaint yourself with C++ strings, this fact should be reassuring. No matter which programming idiom you choose, there are really only about three things you want to do with a string:

  • Create or modify the sequence of characters stored in the string.
  • Detect the presence or absence of elements within the string.
  • Translate between various schemes for representing string characters.
M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on since 2004.
Related Post