Home »
C++ STL
Introduction to C++ STL (Standard Template Library)
By Amit Shukla Last updated : December 11, 2023
Purpose
In this tutorial, we study about the introduction of standard template library. We understand why we create standard template library? What are the uses of standard template library and History of Standard template library?
STL (Standard Template Library)
The STL (Standard Template Library) in C++ is the collection of different algorithms and class templates. STL allows a programmer to implement the basic predefined data structures easily and effectively. STL basically provide us the data structure like stacks, lists, vectors, and queues. Standard template library also allows a programmer to implement many algorithms directly using predefined functions.
STL (Standard Template Library) is basically a library which contains classes, algorithms and integrators. This library contains helper class and function templates. We can use these functions directly instead of typing the full program of basic functions and operations. STL (Standard Template Library) enables generic programming in C ++. Each generic algorithm can operate over any iterator for which the necessary operations are provided. It also supports new algorithm, containers and integrators. It makes easy to code in C ++ language.
C ++ STL Containers
The C ++ STL (Standard Template Library) provides programmers with the following constructs, that were grouper into three categories:
-
Containers
- C++ Stacks
- C++ Queues
- C++ Priority Queues
-
Associative Containers
- C++ Maps
- C++ Bit sets
- C++ Multi maps
- C++ Sets
- C++ Multisets
-
Sequences
- C++ Vector
- C++ List
- C++ Double ended Queues
In the library the hard part of writing the codes to implement complex data structure has already been completed. If one has to use stack of integers, all that he has to do is implementing this code: stack <int> variable;
Anyone can now push () and pop () integers onto this stack by applying minimum efforts. Through the magic of C++ Templates, he could specify any data type, not just integers. Generic functionality of a stack is provided by standard template library.
History of STL (Standard Template Library)
The basic design and idea of creation of STL is created by Alexander Stepanov.
In 1979 Alexander Stepanov started in working out his initial ideas of generic programming and starts exploring their potential for revolution of the software development. David Musser had already developed and advocated some aspects of generic programming already by year 1971, it was limited to a rather specialized area of software development (computer algebra).
Alexander Stepanov is gained the full potential in the field of generic programming. He persuaded his colleagues at General Electric Research and Development that generic programming should be pursued as a comprehensive basis for the software development. At that time there was no support to any of the programming language in the field of generic programming. These were those guys who generate the generic programming in a programming language.
The first programming language which is use to generate the generic library is ADA. This language is chooses because of its generic units features. ADA library published in 1987 by Stepanov and Musser. It is used for list processing that embodied the results of much of their research on generic programming.
The reason for changing the language from ADA to C ++ is that it has fast access due to pointers. In which Stepanov was the C/C++ model of computation which allows very flexible access to storage via pointers is crucial to achieving generality without losing efficiency. Stepanov experimented with many architectural and algorithm formulations, in C and in C++. Musser collaborated in this research and in 1992 Meng Lee joined Stepanov's project at HP and became a major contributor.
Andrew Koenig of Bell Labs had not knows anything about the work due to this he asked Stepanov to present the main ideas at a November 1993 meeting of the ANSI/ISO committee for C++ standardization.
The committee's response was overwhelmingly favorable and led to a request from Koenig for a formal proposal in time for the March 1994 meeting.
Hewlett-Packard's decided to make the implementation of STL (Standard Template Library) and considerably improve the library. In August 1994 decided to make its implementation freely available on the internet this implementation, developed by Stepanov, Lee, and Musser during the standardization process. Now it became the basis of many implementations offered by compiler and library vendors today.
Useful Resources