c&c++--Standard Library

Source: Internet
Author: User
Tags bitset cmath


1. What is the standard library for c&c++?
C language was invented when there is no library function, with the popularity of the C language, more and more manufacturers or organizations began to provide C compiler, and at the same time the frequently used functions encapsulated as a "library" of the form of publishing; Different organizations publish library functions and the number of interfaces varies. Later, the standardization organization ANSI developed the standard of C language, but also developed a certain number of libraries (or library functions), it becomes the standard library function. (The ANSI C standard later rose to the ISO standard, but the content did not change!) Who made America the boss, and C's source of origin is the United States).
C does not have object-oriented features, the C language has been expanded to produce a C + + language, of course, such as ISO standard organization to set standards for it, and accordingly inherit the C language based on the standard library of C + + has appeared.

There are two points to note:
1.c++ 's standard library not only inherits from the C standard library, but also expands many library functions. (There are approximately more than 10 header files in the C standard library, and more than 50 in C + +.) )
The header file of a library in the 2.C language can be applied directly to the source program of C + + (e.g. using #include<math.h>); However, the new rules of the latest C + + standard are not used in this way, but instead use the new C + + method, the #include<cmath >; is "Add head to Tail".


What are the 2.C standard libraries?
They correspond to some header files, respectively:
Assert.h;
ctype.h;
Error.h;
Float.h;
Limits.h;
locate.h;
MATH.H;
Setjmp.h;
signal.h;
Stdarg.h;
stddef.h;
stdio.h;
Stdlib.h;
String.h;
Time.h
A total of 15 header files.


What are the 3.c++ standard libraries?

All header files for the C + + standard library have no extension (#include <cmath>), and in C + + you can use the standard C library header file name in name.h form (this is not recommended!!!). )
The contents of the C + + standard library are defined in a total of 50 standard header files, of which 18 provide the functionality of the C library. The standard header file "<complex> exception" in the form of <cname> has the same content as the Name.h header file contained in ISO standard C, but accommodates the functionality of the C + + extension. In the <cname> form standard header file, the name associated with "macro" is defined in the global scope, and other names are declared in the Std namespace.

The content of the C + + standard library is divided into 10 categories:
1. Language support
2. Input/Output
3. Diagnostics
4. General Tools
5. String
6. Containers
7. Iterator Support
8. Algorithms
9. Numeric operation
10. Localization

1. header files in the standard library that relate to language support features
<cstddef> define macros null and OFFSETOF, and other standard types size_t and ptrdiff_t. The difference from the corresponding standard C header file is that NULL is a supplemental definition of the C + + null pointer constant, and the macro Offsetof accepts the struct or union type parameter as long as they do not have a non-static member of the member pointer type.
<limits> provides definitions related to the base data type. For example, for each numeric data type, it defines the maximum and minimum values that can be represented and the number of digits in the binary digits.
<climits> provides a C-style definition that is related to the basic integer data type. The C + + style definition for this information is in <limits>
<cfloat> provides a C-style definition that is related to the basic floating-point data type. The C + + style definition for this information is in <limits>
<cstdlib> provides the macros and functions that support program startup and termination. This header file also declares a number of other miscellaneous functions, such as search and sort functions, from strings to numeric functions. It differs from the corresponding standard C header file Stdlib.h, which defines abort (void). The abort () function has additional functionality that does not call destructors for static or automatic objects, nor does it call functions passed to the atexit () function. It also defines the extra functionality of the exit () function, which can release a static object and invoke a function registered with atexit () in reverse order of registration. Clears and closes all open C streams and returns control to the host environment.
<new> support dynamic memory allocation
<typeinfo> support for type identification of variables during runtime
<exception> support exception handling, which is one way to handle errors that may occur in a handler
<cstdarg> supports functions that accept variable numbers of parameters. That is, when you call a function, you can send data items of varying amounts to the function. It defines macros Va_arg, Va_end, Va_start, and va_list types
<csetjmp> provides functions for non-local jumps of C-style. These functions are not commonly used in C + +
<csignal> provides C-style support for interrupt handling

2. header files that support stream input/output
The < iostream> supports the input and output of standard flow cin, cout, Cerr, and clog, and it also supports multibyte character standard streams wcin, Wcout, Wcerr, and Wclog.
<iomanip> provides a manipulation program that allows changing the state of the stream, thereby altering the format of the output.
<ios> defining the base class for iostream
<istream> defining template classes for input to the management output stream buffers
<ostream> Defining template classes for the output of the management output stream buffers
<sstream> stream input and output with string support
<fstream> stream input and output of supporting files
<iosfwd> providing forward declarations for input and output objects
<streambuf> support for streaming input and output caching
<cstdio> provides C-style input and output for standard streams
<cwchar> C-style input and output that supports multibyte characters

3. header files related to diagnostic functions
<stdexcept> defines a standard exception. Exceptions are the way to handle errors
<cassert> defining an assertion macro to check for scenarios during run time
<cerrno> support for C-style error messages

4. Define the header file for the tool function
<utility> defines overloaded relational operators, simplifies the writing of relational operators, and defines the pair type, which is a type of template that can store a pair of values. These functions are used elsewhere in the library
<functional> defines a number of function object types and functions that support function objects, which are arbitrary objects that support the operator () () function call operator
<memory> define a standard memory allocator for containers, functions that manage memory, and auto_ptr template classes
<ctime> Support System clock function

5. Header files that support string processing

<string> provides support and definitions for string types, including single-byte strings (consisting of char) string and multibyte strings (made up of wchar_t)
<cctype> Single-byte character categories
<cwctype> Multibyte character category
<cstring> provides functions for handling non-empty byte sequences and memory blocks. This differs from the corresponding standard C library header file, where several C-style strings of generic C library functions are returned with a value of const and non-const function pairs instead of
<cwchar> provides functions for processing, performing I/O, and converting multibyte character sequences, which differs from the corresponding standard C library header files, and the general C library functions of several multibyte C-style string operations are replaced by the return values for const and non-const function pairs.
<cstdlib> provides functions for converting single-byte strings to numeric values, converting between multibyte characters and multibyte strings

6. Header file that defines the template for the container class
<vector> defines a vector sequence template, which is a type of array that can be re-set in size, safer and more flexible than a normal array
<list> defines a list sequence template, which is a series of linked lists that often insert and delete elements at any location
<deque> define deque sequence templates to support efficient insert and delete operations at the start and end
<queue> defining sequence adapters for queue (FIFO) data structures queue and priority_queue
<stack> Defining a sequence adapter stack for a stack (last-in-first-out) data structure
<map> map is an associative container type that allows for uniqueness based on key values and is stored in ascending order. Multimap is similar to map, but the key is not unique.
<set> set is an associative container type used to store unique values in ascending order. Multiset is similar to set, but the value does not have to be unique.
<bitset> defines a bitset template for a fixed-length bit sequence, which can be considered a fixed-length compact bool array

7. header files that support iterators
<iterator> providing definitions and support for iterators

8. header file for the algorithm
<algorithm> provides a set of algorithm-based functions, including permutation, sorting, merging, and searching
<cstdlib> declaration C Standard Library functions bsearch () and qsort () for searching and sorting
<ciso646> allows you to use and in code instead of &&

9. header file for numeric operations
<complex> support for the definition and operation of complex numeric values
<valarray> support for numeric vector operations
<numeric> defines a set of general mathematical operations on a numeric sequence, such as accumulate and inner_product
<cmath> This is the C math library, which also has an overloaded function attached to support C + + conventions
The <cstdlib> provides a function to extract the absolute value of an integer and to take a remainder operation on an integer

10. About Localized header files
<locale> provides localization including character categories, sort sequences, and currency and date representations.
<clocale> provide C-style support for localization

c&c++--Standard Library

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.