C ++ standard library (2)

Source: Internet
Author: User
Tags bitset

From: http://www.cnblogs.com/growup/archive/2012/01/07/2315557.html

 

Connection and difference between a C ++ standard library and STL (Standard Template Library)
STL is the standard template library, which includes six main components: algorithm (algorithm), container (container), Space distributor (Allocator), iterator (iterator), function object (functor), adapter (adapter ).

Qin Note: According to Hou Jie's STL source code analysis: the relationship between the six major components is:

The container uses allocator to obtain the data storage space. algorithm uses iterator to access the container content. functor assists Algorithm in completing different policy changes, and the adapter modifies or configures functor.

 

STL is part of the C ++ standard library, but not all. The C ++ standard library is all the content in the STD namespace, that is, header files without. H, such as <cstdio> and <iostream>. For example, STD: string and IO streams do not belong to STL, but they are STL-compatible and can be applied to iterators and algorithms. Although STD: string and IO streams are template classes, they do not belong to STL.
STL implementation, such as the IO stream and string class included in stlport, cannot be exactly called STL implementation, but is a larger library implementation than STL. However, some STL classes are not implemented in the standard library, such as hash map and stlport. The C ++ standard library contains an STL implementation, but this implementation is a subset of the standard STL.

Feature Classification of C ++ standard library

All header files in the C ++ standard library do not have an extension. The content of the C ++ standard library is defined in a total of 50 standard header files, 18 of which provide the function of the C library.

<Cname> standard header file [<complex> exception] contains the same content as the name. h header file in ISO Standard C, but supports the C ++ Extension function.

In the header file in the <cname> Format standard, macro-related names are defined in the global scope, and other names are declared in the STD namespace. In C ++, you can also use the standard C library header file name in the form of name. h.

The content of the C ++ standard library is divided into 10 categories.:
The C1. language supports C2. input/output C3. diagnostic C4. general tool C5. string
C6. container C7. iterator supports c8. algorithm c9. numerical operation c10. Localization

Header files related to the language support function in the C1 standard library

  1. <Cstddef> define macro null and offsetof, and other standard types of size_t and ptrdiff_t. The difference with the corresponding standard C header file is that null is a complementary definition of the NULL pointer constant in C ++, and the macro offsetof accepts the structure or joint type parameters, as long as they do not have non-static members of the member pointer type.
  2. <Limits> defines basic data types. For example, for each numeric data type, it defines the maximum and minimum values that can be expressed and the number of digits of the binary number.
  3. <Climits> provides the C style definition related to the basic integer data type. The C ++ style of the information is defined in <limits>
  4. <Cfloat> provides C style definitions related to basic floating point data types. The C ++ style of the information is defined in <limits>
  5. <Cstdlib> provides macros and functions that support program startup and termination. This header file also declares many other miscellaneous functions, such as search and sorting functions, from string to numeric functions. Unlike the corresponding standard C header file stdlib. H, it defines abort (void ). The abort () function also has additional functions. It neither calls the Destructor for static or automatic objects, nor calls the function that is passed to the atexit () function. It also defines additional functions of the exit () function, which can release static objects and call the functions registered with atexit () in reverse order. Clear and close all open C streams and return control to the host environment.
  6. <New> support for dynamic memory allocation
  7. <Typeinfo> supports the type identification of variables during running
  8. <Exception> exception handling is supported. This is a possible error in the processing program.
  9. <Cstdarg> supports functions that accept variable parameters. That is, when you call a function, you can send data items of a different number to the function. It defines the macro va_arg, va_end, va_start, and va_list types.
  10. <Csetjmp> provides functions for C-style non-local jumps. These functions are not commonly used in C ++.
  11. <Csignal> provides C style support for interrupt handling

C2 supports Stream Input/Output header files

  1. <Iostream> supports the input and output of standard streams Cin, cout, cerr, and clog. It also supports multi-byte standard streams wcin, wcout, wcerr, and wclog.

  • <Iomanip> provides a control program that allows you to change the stream status and output format.
  • <IOS> define the base class of iostream
  • <Istream> defines a template class for the input in the output stream cache area.
  • <Ostream> defines a template class for the output of the output stream cache area.
  • <Sstream> supports Stream Input and Output of strings
  • <Fstream> supports Stream Input and Output of files.
  • <Iosfwd> Provide Forward Declaration for input and output objects
  • <Streambuf> supports stream input and output caching.
  • <Cstdio> provides C-style input and output for standard streams
  • <Cwchar> supports multi-byte C-style Input and Output
  • Header files related to the diagnosis function of C3

    1. <Stdexcept> A standard exception is defined. Exception is the way to handle errors

  • <Cassert> defines an assertion macro to check conditions during running.
  • <Cerrno> supports C-style error messages.
  • Header file of C4 definition tool function

    1. <Utility> defines overloaded Relational operators to simplify the writing of Relational operators. It also defines the pair type, which is a template type and can store a pair of values. These functions are used elsewhere in the library

  • <Functional> defines many function object types and functions that support function objects. Function objects are arbitrary objects that support operator () function call operators.
  • <Memory> define a standard memory distributor for the container, memory management function, and auto_ptr template class
  • <Ctime> supports system clock functions
  • C5 header files that support string processing

    1. <String> supports and defines string types, including single-byte strings (consisting of char) and Multi-byte strings (consisting of wchar_t)

  • <Cctype> single-byte character type
  • <Cwctype> multi-Byte Character Type
  • <Cstring> provides functions for processing non-empty byte sequences and memory blocks. This is different from the corresponding standard C library header file. The C library functions of several C style strings are replaced by the function pairs that return the const and non-const values.
  • <Cwchar> provides functions for processing, executing I/O, and converting multi-byte character sequences, which is different from the corresponding standard C-library header file, the C-database functions of several multi-byte C-style string operations are replaced by function pairs that return values of const and non-Const.
  • <Cstdlib> provides a function to convert a single-byte string to a numeric value and between multi-byte characters and multi-byte strings.
  • C6 defines the header file of the container class template

    1. <Vector> defines the vector sequence template, which is an array type that can be reset by size, which is safer and more flexible than normal arrays.
    2. <List> defines a list sequence template, which is a sequence linked list. elements are often inserted and deleted at any location.
    3. <Deque> defines the deque sequence template and supports efficient insertion and deletion at the beginning and end.
    4. <Queue> defines the sequence adapter queue and priority_queue for the queue (first-in-first-out) Data Structure
    5. <Stack> defines a sequence adapter stack for the data structure of the stack (before, before, after, and after ).
    6. <Map> map is an associated container type. It can be stored in ascending order according to the key value. Multimap is similar to map, but the key is not unique.
    7. <Set> set is an associated container type used to store unique values in ascending order. Multiset is similar to set, but the value does not have to be unique.
    8. <Bitset> defines a bitset template for a bit sequence with a fixed length. It can be seen as a fixed-length, compact bool array.

    C7 supports iterator header files

    1. <Iterator> defines and supports the iterator.

    C8 header files related to Algorithms

    <Algorithm> provides a set of algorithm-based functions, including replacement, sorting, merging, and search.

  • <Cstdlib> declare the C standard library functions bsearch () and qsort () for search and sorting.
  • <Ciso646> allow and substitution in code &&
  • C9 header file for numeric operations

    1. <Complex> supports the definition and operation of complex values.

  • <Valarray> supports numeric vector operations.
  • <Numeric> defines a set of general mathematical operations on a numerical sequence, such as accumulate and inner_product.
  • <Cmath> This is the C math library, which also attaches heavy-load functions to support the C ++ conventions.
  • <Cstdlib> the function can extract the absolute value of an integer and perform the remainder operation on the integer.
  • C10 header files for localization

    1. <Locale> localized features include the character category, sorting sequence, and currency and date representation.

  • <Clocale> C style support for localization
  • 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.