standard template library c++
The Standard Template Library – STL provides a set of C++ container classes and template algorithms designed to work together to produce a wide range of useful functionality. Though only a small number of container classes are provided, they include the most widely useful containers, such as vectors, lists, sets and maps. The template algorithm components include a broad range of fundamental algorithms for the most common kinds of data manipulations, such as searching, sorting, and merging.
The critical difference between STL and all other C++ container class libraries is that STL algorithms are generic: every algorithm works on a variety of containers, including built-in types, and many work on all containers. Initially we will look at why and how of generic algorithms and other key concepts that give STL many advantages over other software libraries. One of the most important concepts of STL is the way generic algorithms are defined in terms of iterators, which generalize C/C++ pointers, together with the way different kinds of iterators are defined for traversing the different kind of containers. Beside containers, generic algorithms, and iterators, STL also provides function objects which generalize ordinary C/C++ functions and allow other components to be efficiently adapted to a variety of tasks. The library also includes various other kinds of adapters for changing the interfaces of containers, iterators, or functions objects. Storage management in STL is controlled by yet another component type, allocators. All these components are discussed in the STL overview in my coming posts.
STL is only part of a large software library, the C++ standard library approved by the ANSI/ISO C++ committee in the International Standard for C++. Nevertheless, STL remains a coherent framework of fine-grained, interchangeable components that deserve treatment separate from the rest of the C++ Standard Library.
Following topic are under STL,
1. About STL
2. make_pair in stl
3. Containers
a. Sequence Container
a1. vector
a2. deque
a3. list
b. Associative Container
c. container adaptors
4. Iterators
a. Examples of Using Associative Containers
a1. Examples of Using Sets & Multisets
a2. Examples of Using Map & Multimaps
a3. Maps as Associative Arrays
b. Iterator Category
b1. Bidirectional Operator
b2. Random Access Operator
5. Algorithm
a. STL Ranges
6. Iterator Adapters
a. Insert iterators
b. Stream iterators
c. Reverse iterators
7. Manipulating Algorithm
a. Removing Elements
8. Functions as Algorithm Arguments
a. Examples of using Functions as Algorithm Arguments
b. predicates
b1. unary predicate
b2. binary predicate
9. Function Objects
a. What are Function Objects
b. Advantage of Function Objects
c. Predefined Function Objects
10. Container Elements
a. Requirements for container elements
b. Value semantics or Reference Semantics
11. Errors and Exceptions Inside the STL
a. Error Handling
b. Exception Handling
12. STL Containers
a. Common Container Abilities and Operations
a1. Common Container Abilities
a2. Common Container Operations
b. Vectors
b1. Abilities of Vectors
b2. Vector Operations
b3. Using Vectors as Ordinary Arrays
b4. Examples of Using Vectors
b5. Class vector<bool>
c. Deques
c1. Abilities of Deques
c2. Deque Operation
c3. Example of Using Deque
d. Lists
d1. Advantage of Lists
d2. List Operations
d3. Example using List
d4.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
STL Sample Codes
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- vector
- deque
- list
- Iterators
- set
- multiset
- map
- multimap
- Maps as Associative Arrays
- insert iterator
- stream iterator
- reverse iterator
- list remove
- for_each
- transform algorithm
- find_if example (unary predicate)
- binary predicate
- using function object
- predefined function objects
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Reference Books for C++ Standard Template Library
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library by Scott Meyers
- The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis
- STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library (paperback) (2nd Edition) (C++ in Depth Series) by David R. Musser, Gillmer J. Derge and Atul Saini
- The C++ Standard Template Library by P.J. Plauger, Alexander Stepanov, Meng Lee and David R. Musser
- Generic Programming and the STL: Using and Extending the C++ Standard Template Library by Matthew H. Austern
- Data Structures in C++: Using the Standard Template Library (STL) by Timothy Budd
- Using the STL: The C++ Standard Template Library by Robert Robson
- Data Structure Programming: With the Standard Template Library in C++ (Undergraduate Texts in Computer Science) by Joseph Bergin
- C++ Programmer's Guide to the Standard Template Library by Mark Nelson