
- 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
What's the difference between "STL" and "C++ Standard Library"?
The Standard Template Library (STL) is a software library for the C++ programming language that influenced many 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. 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, which are containers with a 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 backward) 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.
In the C++ programming language, the C++ Standard Library is a collection of classes and functions, which are written in the core language and part of the C++ ISO Standard itself. The C++ Standard Library provides several generic containers, functions to utilize and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and functions for everyday tasks such as finding the square root of a number. Following are some of the features of the C++ standard library −
Streams
These libraries are used to deal with different types of streams available in C++. For example, a stream represents the file stream generally, and this class can be used to create files, write information to files, and read information from files, a stream represents a string stream and is generally used to manipulate strings, etc.
Containers
This is a collection of classes that are used to store data in various data types like vectors, sets, maps, stacks, queue, etc. These are a component of the STL.
General libraries
Libraries like algorithm, Chrono for time, iterator, memory, etc.
Numerics library
This library is a collection of components that C++ programs may use to perform seminumerical operations. For example, <complex> defines a class template, and numerous functions for representing and manipulating complex numbers, <random> is used for generating (pseudo-)random numbers, etc.
Threading
This is a library introduced in C++11 that basically deals with concurrency.
C Standard Library
Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the .h, and adding a 'c' at the start; for example, 'time.h' becomes 'ctime'.
- Related Articles
- The C++ Standard Template Library (STL)
- 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)
- Library in C++ STL?
- C++ Standard Library Header Files
- Difference Between Beta and Standard Deviation
- Difference between Header file and Library
- Difference between Bretton Woods System and Gold Standard
- Difference between .extend() / .assign() and .merge() in Lodash library.
- What are the most useful Python modules from the standard library?
- Difference between two times using Dayjs JavaScript library?
- Difference between C and C++.
