DEV Community

Mansi Tibude
Mansi Tibude

Posted on

Standard Template Libraries in C++:

The Standard Template Libraries are used for fast computing and handling huge data. It is fast and efficient as compared to other standard libraries and various inbuilt classes are present in it. The essential libraries and classes used while making programs using STL are:

Vector:

-Vectors are dynamic sized array in Standard Template Libraries in C++ programming language.
-The elements are added, the size of vector automatically grows.
-Operations performed in vectors: add(), remove(), access(), modify().
-The operations performed using vectors are push_back(), insert(), size(), begin(), at(), pop_back(), erase(), find(), empty().
-Most commonly used libraries: Vector, IOStream, Algorithm.
-We can also create multi-dimensional vectors: two dimensional vectors or implementing vectors inside vector.

Templates:

-Templates are classes and functions, written for more than one types.
-Portable way of using templates are implementing them in header files, and exporting them.
-Non-Type Template Parameters are templates where we can pass number of bits as template argument.
-Type-name in template are identifiers that follows a type and used to clarify the sub-type inside the template class and template of identifier is considered as value. Type-name can be used as class too.
-Any datatype which are used inside the template must have inner definition.

Member Template:

-Member functions of templates are functions.
-Member Templates, whether they are virtual or not, must have default parameters.
-Member templates also, support automatic type conversion.

Stream Functions:

-cout: Used for printing in console.
-cin: Used to take input from terminal.
-cerr: Used for printing error to consoles.
-clog: Used for printing log messages to the console.

Different kinds of templates:

-Non-Type Template Parameters.
-Default Template Parameters.
-Member Templates.

Standard Template Libraries important things to keep in mind.

Top comments (0)