Alexander Stepanov and Meng Lee of Hewlett-Packard developed a set of general-purpose templatized classes and function for storing and processing of data.
So, The collection of these generic classes is called Standard Template Library(STL).
The STLs has now become a part of the ANSI standard C++ library.
Using STL, we can save considerable time and effort, and lead to high-quality programs.
Moreover, All these benefits are possible because we are basically “reusing” the well-written and well-tested components defined in the STL.
Also, STLs components which are now part of the standard C++ library are defined in the namespace std.
We must, therefore, using namespace directive, to intend to use the Standard C++ library.
using namespace std;
List out components of STL and explain in short.
There are three core components of STL as follows:
Moreover, These three components work in conjunction with one another to provide support to a variety of programming solution.
The relationship between the three components is shown in the following figure,
A container is an object that actually stores data.
Moreover, It a way data organized in memory.
The STLs containers implemented by template classes and therefore can easily customize to hold different types of data.
An algorithm is a procedure that used to process the data contained in the containers.
Also, The STLs includes many different kinds of algorithms to provide support to take such as initializing, searching, copying, sorting, and merging.
Algorithms implemented by template functions.
The iterators is an object(like a pointer) that points to an element in a container.
Moreover, We can use iterators to move through the contents of containers.
Iterators handled just like pointers.
Also, We can increment or decrement them.
Iterators connect algorithms with containers and play a key role in the manipulation of data stored in the containers.