STL and C ++ Standard Library (3)

xiaoxiao2021-03-06  75

STL is a subset in the latest C standard library, which accounts for approximately 80% of the entire library. As a template that plays key roles in the STL process is filled with almost the entire C standard function library. Here, we need to see which contents contain in the C standard library, which are those belonging to a standard template library (ie STL).

The C standard library provides an extensible basic framework for C programmers. We can achieve great convenience from it, and we can expand it by inheriting existing classes, compliance with intervenes, algorithms, iterative materials, etc. It roughly includes the following components:

The C standard function library has basically maintained a good compatibility with the original C language library, although some micro-changes. People will always can't help but have a beautiful year, if you have been a C programmer, you must feel deeply. Perhaps you will make you feel strange, that is, there are two sets of C standard libraries, a set of .H extensions (such as ), and another set is not For example, ). They don't have much different.

Language Support section, contains some definitions of standard types and other features, which are used in other parts of the standard library or in specific applications.

Diagnostics section provides three ways for program diagnostics and error, including exception handling, assertion, error code, error code.

General utilities section, this part of this part provides support for the other parts of the C standard library, of course, you can also call the appropriate functions in your own program. For example: Dynamic Memory Management Tools, Date / Time Processing Tools. Remember, the content here has also been generalized (ie, a template mechanism) is used.

String section, used to represent and process text. It provides a rich feature. In fact, the text is a String object, which can be seen as a character sequence, the character type may be char, or Wchar_t, etc. String can be converted to a char * type, which can be a peaceful coexistence with the previously written C / C code. Because at that time, there was no other than CHAR *.

INTERNATIONALIZATION section And time representation, numerical and currency processing, etc.. After all, in China and in the United States, people express their habits of the date.

A containers section, an important part of STL covers many data structures, such as the list previously mentioned, and: Vector (similar to the number of magnifications), Queue (Queue), Stack (Stack ) ... String can also be seen as a container, and the method suitable for containers is also applicable to String. Now you can easily complete the homework of the data structure course. Algorithms section, an important part of STL contains approximately 70 general algorithms for manipulating various containers, while also manipulating an array. For example, Find is used to find an element equal to a particular value in the container, and for_each is used to apply a function to each element in the container, and SORT is used to sort the elements in the container. All of these operations are made under the premise of performing efficiency, so if the program becomes efficient after you use these algorithms, you must first do not doubt these algorithms itself and carefully check the other places of the program.

An important part of the iterators section, STL, if there is no iterator, the container and algorithm are unable to combine such perfect. In fact, each container has its own iterator, only the container knows how to access your own elements yourself. It is a bit like a pointer, and the algorithm is positioned and controlled in the container through an iterator.

A NuMerics section contains some mathematical computing functions, providing support for complex operations.

Input / Out / Output part, is the Iostream section in the templated original standard library, which provides basic support for the input and output of the C program. It is functionally compatible with the original Iostream and has increased the mechanism for exception processing and supports internationalization.

Overall, in the C standard library, STL mainly includes containers, algorithms, and iterators. String can also be counted as part of the STL.

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

New Post(0)