STL source code analysis

xiaoxiao2021-03-06  47

Chap1 1. The value of STL is two aspects: first, just like MFC and VCL, we provide some necessary support for our RAID development. Another aspect is from the perspective of design patterns and truly realizes an abstract implementation library based on generic thinking. That is, the STL is implemented in accordance with a conceptual structure set up in generic thinking, which is a structure in which the abstract concept is the main body rather than the actual class. Form a rigorous interface standard. Under this abstract interface, each component has the largest independence, bonding different components by so-called Iterator, or adapted to each other in an Adapter. Or dynamically select some strategy with the Funtor. Although the C language can achieve basic type of parameterization, it has not yet risen to STL. 2. STL's 6 major components 1. The common data structure of Container is used by Vector, List, Deque Set Map is used to store data. In the specific implementation, it is a template class class, which is implemented in a specific implementation. 2. Algorithm Various common algorithms, SORT, Search, Copy, ERASE algorithm implementation is achieved by a function template. 3. Iterator is equivalent to a Smart Pointer from an implementation point of view, iterator is a Class Template 4. Functor, which is overloaded by Operator , Opertator -, Operator ->, Operator *, can be used as a policy of algorithm policy At an implementation point, Functor is a class template with Operator () 5. ADAPTERS is a thing used to modify the container or an imitation function or an iterator interface. 6. Allocator is responsible for space allocation and management . From an implementation point of view, the configurator is a Class Template that implements the dynamic space configuration. I can be the content of the SGI version may be the implementation of the SGI version; 3. SGI STL compiler configuration settings in some compilers do not full support can only be configured via the config file: If the compiler can not handle static function template class, you need to define __STL_STATIC_TEMPLATE_MEMBER_BUG if the compiler supports partial specilization of class template __STL_CLASS_PARTIAL_SPECIFICATION if the compiler supports part specilazation function template definition __STL_FUNCTION_TMPL_PARTIAL_ORDER if the compiler supports template class function member template class __STL_MEMBER tEMPLATE variable is if the compiler supports non-type template argument that if the compiler does not define __STL_NO_TYPE_TMPL_PARAM_BUG -> operator is defined __SGI_STL_NO_ARROW_OPERTATOR if the compiler supports exception handling so _ _STL_USE_EXCEPTIONS If the compiler supports multi-thread __stl_win32thread If the compiler supports Assert, then defined __stl_assertation

转载请注明原文地址:https://www.9cbs.com/read-78899.html

New Post(0)