- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What's the difference between "STL" and "C++ Standard Library"?
45 Lectures 4.5 hours
66 Lectures 5.5 hours
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
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.
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 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 −
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.
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.
Libraries like algorithm, Chrono for time, iterator, memory, etc.
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.
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'.
- 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)
- What's the difference between sizeof and alignof?
- What's the difference between window.location and document.location?
- What's the difference between Matplotlib.pyplot and Matplotlib.figure?
- Difference between Header file and Library
- What's the difference between Tkinter's Tk and Toplevel classes?
- What is the difference between Python's re.search and re.match?
- What's the difference between lists and tuples in Python?
- What's the difference between RSpec and Cucumber in Selenium?
- Difference Between PGP and S/MIME