Standard Template Library
|
 |
The Standard Template Library
forms the core of the Standards<ToolKit>.
Most C++ programs require the
ability to use collections, such as arrays, lists, and sets. Until now, C++
programmers either had to write their own collection classes or purchase a
proprietary commercial product. Non-standard commercial offerings have one or
more of the following drawbacks.
- Incompatibility among
vendors-Because there was no standard for collection classes, every
vendor's collection classes were incompatible. This caused difficulty in
deciding how to return a collection of results from a function call, because
multiple users of a function might be using collections from different
vendors.
- Use of virtual functions-Many
collection hierarchies use inheritance and virtual functions, which tend to
reduce performance. Although in many cases this is not a problem, many
programmers do not want to use libraries unless they perform within a few
percentage points of hand-coded C equivalents. Use of virtual functions also
makes objects difficult to instantiate in shared memory.
- Difficulty in adding new
algorithms-Commercial vendors place their code for algorithms that work
on collections within the collection class. For example, code for sorting
often ends up in a collection called "SortedCollection," and code
for applying a function to every element in a collection often ends up in an
abstract base class called "Collection." This approach makes it
hard to add new algorithms without editing and recompiling the vendor's
source code, which is best to avoid for maintenance reasons.
- Not type-safe-Several
commercial collection classes are not type-safe. Use of these collections
require heavy use of casting, which goes against one of the main spirits of
C++ development (strict type checking).
- Use of heap memory-All
of the commercially available collection classes have their memory
allocation policies woven deeply into the code of the containers. This means
you cannot allocate space for a collection from shared memory instead of
from the heap.
In response to these problems, the
American National Standards Institute (ANSI) committee in conjunction with the
International Standards Organization (ISO) decided to search for a standard set
of collection classes that would overcome these difficulties.
Alex Stepanov and Meng Lee proposed a template
container and algorithms library based on their work in the area of generic
programming. In July of 1994, their work was selected as the standard, and the
Standard Template Library (STL) was born.
The
Standard Template Library (STL) is comprised of the following
components.
- Containers-
Generalized classes used to hold a collection of typed data
- Iterators-Generalized
pointers used to traverse the elements of a container
- Algorithms-Procedures
that can be applied on all or part of a container
- Function Objects-Behaviors
used as a parameter by a container or algorithm
- Allocators-Objects
responsible for allocating storage
Standards<ToolKit> includes
an optimized implementation of the Standard Template Library, in addition to
other components in the Standard C++ Library. A templatized string class
supporting both ASCII and wide-character sets is included, as well as the
Standard Exception Hierarchy and utility classes. Recursion Software firmly
believes in standards conformance, and consequently all of our libraries use the
Standard C++ Library both internally and in our class interfaces.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.