5.1 How components work together

To make it clear how all STL components work together the relations between the components are topic of this section.

Containers store objects of arbitrary types. Containers are parametrized by allocators. Allocators are objects which encapsulate information about the memory model used. They provide memory primitives to handle memory accesses uniformly. Every memory model has its characteristic, tailor-made allocator. Containers use allocators to do their memory accesses. A change of the memory model used leads to a change of the allocator object given as an argument to the container. This means, that on the code level a container object is invariant under different memory models.

An algorithm is a computation order. So, two algorithms should differ in the computations done by them, not in the access method used to read input data and write output data. This can be achieved when data is accessed in a uniform manner. STL provides a uniform data access mechanism for its algorithms - iterators. Different iterators provide different access modes. The basic input and output unit is the range, which is a well-defined sequence of elements. Function objects are used in combination with algorithms to encapsulate, for example, predicates, functions and operations to extend the algorithms' utility.

Adaptors are interface mappings, they implement new objects with different or enhanced functionality on the basis of existing components.

It has to be said that this decomposition of the component space is arbitrary to a certain extent but designed to be as orthogonal as possible. This means that interferences between components are reduced as far as possible.

The clean, orthogonal and transparent design of the library shall help to

Continue with section 5.2

Back to index


Johannes Weidl (J.Weidl@infosys.tuwien.ac.at) - Apr 16, 1996