Introduction to STL
We have studied about the template that enables us to do generic programming. Generic functions or classes support all data types. The standard template library is an advance application of templates. It contains several in-built functions and operators that help the programmer develop complex programs. The programmer only needs to include an appropriate header file to use the function or operator from the file, such as library functions. The STL library helps write a bug-free program. In case any bug presents, it is easy to debug it. For example, if a programmer wants to create a link list, he/she may require to write a program that may be of 40 to 50 lines. However, using STL functions (list algorithm), it is a task of a few minutes.
The Standard Template Library (STL) is a new feature of C++ language. All famous compiler vendors provide the STL as a feature of their compilers. STL is vast and heterogeneous collection of reusable container classes. It consists of vectors, lists, queues, and stacks. The STL is portable with various operating systems.
The Meng Lee and Alexander Stepanov of Hewlett-Packard introduced the STL and accepted it in 1994 as an addition to the customary C++ library. The STL provides well-coded and compiled data structures and functions that are helpful in generic programming; and it is reusable. The STL topics are very vast; hence, their complete description is beyond the scope of this book. Only major features are explained. STL contents are defined in the namespace std. It is essential to write the statement using namespace std at the beginning of the program.