1. Why to build STL: The improvement of the reusability of the program (based on the standard)
2, the value of STL:
1) STL brings the most useful components
2) "Taxonomy of software Components" based on generic thinking
3, a sentence summed up the STL
STL implements an interface standard that is based on an abstract conceptual framework.
Under this interface, any component is independent of each other, any component is glued through iterator, adaptor by a functor, and selected by the
Policy
4. STL Formation
Class: Custom Category
Template: Parameterization of categories
Traits: Programming Tips
Through this three, the formation of STL
5, the STL six major components
1. Container container: The structure of the data-- is a class template (Vector,list,deque,set,map)
2, Algorithm algorithm: is a function template (Sort,search,copy,erase ..... )
3, iterator iterator: the glue between the container and the algorithm, the so-called "generic pointer"; is a class template that overloads the operator* pointer operation
4, imitate function functor: behavior similar function, can be used as a kind of strategy of the algorithm; is a class or class template that overloads operator ()
5. Adapter adaptor: something that modifies the interface of a container, an imitation function, an iterator (stack,queue--bottom with deque)
6, Configurator allocator: Responsible for space configuration and management, is a dynamic space configuration, space management, space release of the class template
6, STL Six components interactive relationship:
Container through the allocator to obtain data storage space, algorithm through iterator access container content, functor can assist algorithm and according to different strategies to change words, Adaptor can be modified or socket functor
7. STL Configuration (SGI)
SGI STL prepared an Environment configuration file <stl_config.h>, which defines a number of constants, indicating whether certain components are set up, all STL header files will indirectly or directly contain the configuration file, and a conditional notation oh, Let Pre-processor decide which program code to choose according to each constant
8, temporary Object- applied to imitate function and algorithm collocation
Temporary objects: Nameless objects, which are not expected to create an efficiency burden
( a copy operation is triggered by a value call, resulting in a temporary object)
Deliberately create temporary objects: Add () after the type name and specify an initial value of Eg:shape (3,5) or int (8), equivalent to invoking the appropriate construct, but not specifying the object name
9. Static constant Shaping data member (integer type not equal to int) gives initial value directly within class
static const Int/short/long/long Long/char xxxx=123;
10, ++,--, * in the iterator occupies an important position, as much as possible to use the front, less use the rear
predecessor return value, ++i,i reference
Post-return value, I++,i Const temporary object before self-increment
The post-implementation is built on a front-facing basis
11, iterator the range is "First,last", the actual range "First,last-1", last represents the final element of the next position first! =last is often used as a cyclic condition
This article from "Momo is spicy moe" blog, please be sure to keep this source http://momo462.blog.51cto.com/10138434/1769579
1 Introduction to STL Introduction