STL, is a C++ library of container classes, algorithms, and iterators; almost every component in the STL is a template.
Containers and algorithms
The STL includes the classes vector, list, deque, set, multiset, map, multimap, hash_set, hash_multiset, hash_map, and hash_multimap. algorithm is a global function, not a member function , it operates on a range of elements, rather than on a container. In this particular case the range happens to be the entire container . algorithm is decoupled from the STL container classes
Iterators
Pointers themselves are iterators, which is why it is possible to reverse the elements of a C array. Iterators are the mechanism that makes it possible to decouple algorithms from containers: algorithms are templates, and are parameterized by the type of iterator, so they are not restricted to a single type of container.
Concepts and Modeling
the arguments of algorithm's function implicitly defines a set of requirements on types, and that it may be instantiated with any type that satisfies those requirements. we call such a set of type requirements a concept ! We say that a type conforms to a concept, or that it is a model of a concept . programming in terms of concepts, rather than in terms of specific types, makes it possible to reuse software components and to combine components together.
Refinement
Refinement of concepts is very much like inheritance of C++ classes; the main reason we use a different word, instead of just calling it "inheritance", is to emphasize that refinement applies to concepts rather than to actual types.
Other parts of the STL
First, Assignable describes types that have assignment operators and copy constructors; almost all STL classes are models of Assignable, and almost all STL algorithms require their arguments to be models of Assignable .
Second, the STL includes some low-level mechanisms for allocating and deallocating memory. Allocators are very specialized, and you can safely ignore them for almost all purposes.
Finally, the STL includes a large collection of function objects, also known as functors.
本文地址:http://com.8s8s.com/it/it29614.htm