
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
The C++ Standard Template Library (STL)
The Standard Template Library is a software library for the C++ programming language that influenced several parts of the C++ Standard Library. It provides four components called algorithms, containers, functions, and iterators. Note that the term "STL" or "Standard Template Library" does not show up anywhere in the ISO 14882 C++ standard. So referring to the C++ standard library as STL is wrong, ie, STL and C++ Standard Library are 2 different things with the former being the subset of the latter.
The STL consists of −
Containers
The STL contains sequence containers and associative containers. The Containers are objects that store data. The standard sequence containers include vector, deque, and list. The standard associative containers are set, multiset, map, multimap, hash_set, hash_map, hash_multiset, and hash_multimap. There are also container adaptors queue, priority_queue, and stack, that are containers with the specific interface, using other containers as implementation.
Iterators
An iterator is an object that enables a programmer to traverse a container. The STL implements five different types of iterators: input (used to read a sequence of values), output (used to write a sequence of values), forward (that can be read, written to, and move forward), bidirectional (like forward iterators, but can also move backwards) and random access (move freely any number of steps in one operation). Iterators are the major feature that allows the generality of the STL.
Algorithms
Algorithms in STL is a collection of functions specially designed to be used on ranges of elements. A range is any sequence of objects that can be accessed through iterators or pointers, such as an array or an instance of some of the STL containers. Examples of algorithms in STL: sort (Sort elements in range), binary_search (Test if a value exists in sorted sequence), min_element (Return smallest element in range), etc. Note that all these algorithms can be applied to any data type accepted as a template.
- Related Articles
- Sort in C++ Standard Template Library (STL)
- Multiset in C++ Standard Template Library (STL)
- Pair in C++ Standard Template Library (STL)
- Priority Queue in C++ Standard Template Library (STL)
- Binary Search in C++ Standard Template Library (STL)
- What's the difference between "STL" and "C++ Standard Library"?
- Library in C++ STL?
- C++ Standard Library Header Files
- What are the most useful Python modules from the standard library?
- Template Metaprogramming in C++
- Template Specialization in C++
- is_final template in C++
- is_fundamental Template in C++
- is_pod template in C++
- is_pointer Template in C++
