Article Directory
What is STL
STL (standard template libaray-standard template library): is an important part of the C ++ standard library , not only a reusable component library, but also a software framework that includes data structures and algorithms.
STL version
-
The original version
Alexander Stepanov and Meng Lee completed the original version in HP Labs. In the spirit of open source, they stated that they allow anyone to use, copy, modify, disseminate, and commercially use these codes at no cost. The only condition is that it also needs to be open source as the original version. HP version – the ancestor of all STL implementation versions. -
PJ version
Developed by PJ Plauger, inherited from HP version, adopted by Windows Visual C ++, cannot be disclosed or modified. Defects: low readability, weird symbol naming. -
The RW version
was developed by Rouge Wage and inherited from the HP version. It is adopted by C + + Builder and cannot be published or modified. It is generally readable. -
The SGI version
was developed by Silicon Graphics Computer Systems, Inc. and inherited from the HP version. It is adopted by GCC (Linux), has good portability, and can be published, modified or even sold. From the perspective of naming style and programming style, it is very readable. STL to learn later to read part of the source code, the main reference is this version.
Six components of STL
There is a saying on the Internet: "Do not understand STL, don't say you know C ++". STL is an excellent work in C ++. With its companionship, many of the underlying data structures and algorithms do not need to reinvent the wheel by themselves, standing on the shoulders of the predecessors and developing rapidly.
How to learn STL
Three realms of learning STL:
- Usable
- reasonable
- Expandable
Defects of STL
-
The update of the STL library is too slow. This is a serious complaint. The last version is reliable C ++ 98, and the middle C ++ 03 is basically revised. It has been 13 years since C ++ 11 came out, and the STL was updated further.
-
None of STL currently supports thread safety. We need to lock ourselves in a concurrent environment. And the granularity of the lock is relatively large.
-
STL's extreme pursuit of efficiency has led to internal complexity. Such as type extraction, iterator extraction.
-
The use of STL will cause code expansion problems, such as the use of vector / vector / vector will generate multiple copies of the code, of course, this is caused by the template syntax itself.
It's another brand new stage in C ++, continue to cheer, rush duck! !