STL standard template library

Source: Internet
Author: User
Tags mathematical functions

From: http://www.nbrkb.net/lwt/jsjsj/language/STL.htm

STL (Standard Template Library) is an industrial and efficient C ++ library. It is included in the C ++ standard library, which is the latest and revolutionary part of the ANSI/iso c ++ standard. This library contains many basic data structures and algorithms commonly used in the field of computer science. It provides a Scalable Application Framework for the majority of C ++ programmers and highly reflects the reusability of software. This phenomenon is similar to the MFC (Microsoft Foundation Class) in Microsoft Visual C ++.
Library), or the VCL (visual component library) in Borland C ++ builder ).

In terms of logic, STL embodies the idea of generic programming and introduces many new terms, such as requirements ), concept, model, container, algorithm, and iterator. Like polymorphism in object-oriented programming, generics are also a software reuse technique.
From the implementation level, the whole STL is implemented in a type parameterized method, this method is based on a template, a language feature that was not available in earlier C ++ standards ). If you look at any version of STL source code, you will find that the template as the cornerstone of the entire STL is a thousand truth. In addition, many new features of C ++ provide convenience for STL implementation.
STL is a subset of the latest C ++ standard function library, which occupies about 80% of the entire library. The template that plays a key role in the implementation of STL is filled with almost the entire c ++ standard function library. Here, we need to take a look at what is included in the C ++ standard function library, and what is included in the standard template library (STL.
The C ++ standard function library provides a scalable basic framework for C ++ programmers. We can get a lot of convenience from this. At the same time, we can inherit the existing classes and compile containers, algorithms, iterations, and other methods that comply with the interface specifications to expand them. It generally includes the following components:
C Standard function library, basically maintains good compatibility with the original C language library, despite some slight changes. People will always be reluctant to miss the good days of the past. If you were a C programmer, you would have been quite familiar with these 1.1 cases. One thing may surprise you, that is, there are two sets of C function libraries in the C ++ standard library, one. h extension (such as <stdio. h>), but not (for example, <cstdio> ). They are indeed not much different.
The language support section contains definitions of some standard types and other features, which are used elsewhere in the standard library or in specific applications.
Diagnostics provides functions for program diagnosis and error reporting, including Exception Handling, assertions, and error code.
The general utilities Section provides support for other parts of the C ++ standard library. Of course, you can also call the corresponding functions in your program. For example, a dynamic memory management tool and a date/time processing tool. Remember, the content here has been generalized (that is, the template mechanism is used ).
String to represent and process text. It provides rich functions. In fact, text is a string object, which can be considered as a character sequence. The character type may be char or wchar_t. String can be converted to the char * type, so that it can coexist with the previously written C/C ++ code. Because there was nothing except char * at that time.
Internationalization, as one of the OOP features, plays a role in eliminating cultural and regional differences. Using locale and facet can provide a large number of programs with international support, including support for various character sets, representation of dates and times, processing of values and currencies, etc. After all, in China and in the United States, people say that the date habits are different.
Container (containers), an important component of STL, covers a lot of data structures, such as the previously mentioned linked list, And: vector (similar to an array with dynamically increased size), queue (Queue), stack )....... String can also be considered as a container, and the method applicable to the container also applies to the string. Now you can easily complete the homework of the Data Structure course.
Algorithm (algorithms), an important component of STL, contains about 70 common algorithms used to manipulate various containers, and can also manipulate built-in arrays. For example, find is used to search for elements equal to a specific value in the container, 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 these operations are performed on the premise of ensuring execution efficiency. Therefore, if the program becomes more efficient after you use these algorithms, do not doubt the algorithms themselves, check other parts of the program carefully.
Iterators is an important component of STL. Without an iterator, containers and algorithms cannot be combined perfectly. In fact, each container has its own iterator, and only the container itself knows how to access its own elements. It is a bit like a pointer. The algorithm uses an iterator to locate and manipulate elements in a container.
The numeric (numerics) section contains some mathematical functions and provides support for complex operations.
The input/output part is the iostream part of the templated standard library. It provides basic support for input and output of C ++ programs. This feature maintains compatibility with the original iostream, adds an exception handling mechanism, and supports internationalization ).
In general, STL mainly contains containers, algorithms, and iterators in the C ++ standard function library. String can also be regarded as a part of STL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.