C++
Quite a fascinating language isn't it? But people will swear to it that their lives(especially developers) have been made a lot easier with the use of Libraries.
Today I will be talking about
Today I will be talking about
- C Libraries and Headers
- C++ Standard Libraries
- C++ Libraries and Headers
- C++ Standard Template Libraries and Headers
1. C++ Standard Libraries
C++ provides a huge set of libraries:
- Standard ANSI C library ported over to C++. These libraries are name with a prefix "
c
" and without the ".h
", e.g.,<cmath>
for C's<math.h>
,<cstdlib>
for C's<stdlib.h>
, etc. - C++ new Libraries, such as
<iostream>
,<iomanip>
,<string>
,<fstream>
,<sstream>
. - C++ Standard Template Library (STL): consists of containers, iterators, algorithms and function objects.
- Boost C++ libraries.
The cplusplus.com at http://www.cplusplus.com/reference provides a comprehensive online references for the C++ libraries (and updated for C++11).
1.1 C Libraries and Headers
<cstring>
: To be elaborated later.<cmath>
: numeric mathematical library<cstdlib>
: General utilities such as Execution (abort
,exit
,EXIT_SUCCESS
,EXIT_FAILURE
); Environment (getenv
); Dynamic Memory Management (malloc
,free
,calloc
,realloc
), String Parsing (atoi
,atof
,atol
,strtod
), Pseudo-random sequence generation (rand
,srand
,RAND_MAX
); Array searching and sorting (bsearch
,qsort
).<cctype>
:Checkingcharactertypes (isalpha
,isdigit
,isalnum
,isspace
,isupper
,islower
,isblank
,iscntrl
,isgraph
,isprint
,ispunct
,isxdigit
) and character conversion (toupper
,tolower
).<climits>
,<cfloat>
: Size and limit of integer types (INT_MAX
,INT_MIN
,UINT_MAX
,CHAR_BIT
; andSHRT_XXX
forshort
,LONG_XXX
forlong
,LLONG_XXX
forlong long
,CHAR_XXX
forchar
) and floating-point types (DBL_MIN
,DBL_MAX
,DBL_DIG
,DBL_MIN_EXP
,DBL_MAX_EXP
; andFLT_XXX
forfloat
,LDBL_XXX
forlong double
).<ctime>
:time
,difftime
,clock
,gmttime
,localtime
, and etc.<cstdio>
: C's IO operations (scanf
,printf
,fscanf
,fprintf
,fopen
,fclose
, etc)<cassert>
,<cerrno>
,<csignal>
: Diagnostics and error<clocale>
: localizaton<cstdbool>
,<cstdint>
,<cstddef>
,<cstdarg>
:<cuchar>
,<cwchar>
,<cwcchar>
: Unicode characters.
1.2 C++ Libraries and Headers
<ios>
,<iostream>
,<istream>
,<ostream>
,<fstream>
,<sstream>
:<iomanip>
:<string>
:<regex>
:<random>
:<limits>
:<stdexcept>
,<exception>
:<complex>
,<tuple>
,<valarray>
:<locale>
:<typeinfo>
:<chrono>
:- Others:
<codecvt>
,<new>
,<ratio>
,<system_error>
,<type_traits>
.
1.3 C++ Standard Template Libraries (STL) and Headers
STL was developed by Alexander Stepanov and Meng Lee at Hewlett-Packard Lab as proof-of-concept for so-called generic programming. It was released in 1994 and subsequently adopted into the C++98.
STL provides a collection of templates representing containers, iterators, algorithms and function objects.
- A container (templatized data structure) can be used to hold fundamental-type values or almost any type of objects, e.g.,
vector<int>
,list<string>
,deque<Person>
. - An iterator (a generalization of pointer) is an object that lets you transverse through elements of a container, e.g.,
vector<int>::iterator
,list<string>::iterator
. - Algorithms are used for tasks such as searching, sorting and comparison, e.g.,
for_each
,find
,sort
. - Function objects are objects that act like functions.
STL is provided in the following headers:
<vector>
,<list>
,<deque>
,<queue>
,<stack>
,<map>
,<set>
,<bitset>
,<forward_list>
(C++11),<unordered_map>
(C++11),<unordered_set>
(C++11),<array>
(C++11): Containers data structures template classes.<iterator>
: Iterator for transversing the elements in a container.<algorithm>
,<numeric>
,<functional>
,<utility>
: Algorithm and function objects.<initializer_list>
(C++11),<memroy>
(C++11).
1.4 Boost C++ Libraries
[TODO]
NOTE: I will be updating this post as it has incomplete information(Boost c++ libraries)
Continuation of this post is STL Part 2.
Continuation of this post is STL Part 2.
No comments:
Post a Comment