STD Intro
What is C++ the Standard C++ library?
C++ Library is a library of code described by the C++ standard, and it delivers the standard implementation of C++, and it comes with two standard libraries: the old C library (Libc.lib), and the new C++ library (libcp.lib), so in simple words its a collection of classes and functions which are written in the core language, and it is updated every new standard for C++ every 3 years.
So, STD (Standard Library) does not refer to one library file but a collection, and it has been enhanced and incremented with every C++ version.
- The first C++ standard (C++98) the std has:
- STL (Standard Template Library) that containers and algorithms
- Strings library < string >
- I/O streams
- Then in (C++11) in 2011 the std extended to have:
- Regular expressions
- Smart pointers
- Hash tables
- Random numbers
- Time Library
- Multithreading
- Then in (C++14) in 2014:
- Improved Smart pointers
- Improved Multithreading
- Adding Tuples, and type traits.
- Then in (C++17) in 2017:
- Adding String view
- Parallel Algorithm in the STL(Standard Template Library).
- Filesystem Library
- std::any, std::optional, and std::variant types.
Start with C++ STD
So the C++ standard library is a system library that already comes with your compiler package,
and any call needs std namespace from the standard library and by default, the C++ linker links the std library.
c++ version (C++11, C++14, etc) specify which functions and classes is already in this std.
#include
int main()
{
std::cout << "Hello\n";
std::cout << "Hello world" << "\n";
}
it has in general two parts:
- The old library from C language called C STD
- The new library from C++ Language called C++ STL
The two parts are updating every C++ standard release.
C STD
The old library keeps being updated with the great number of functions and macros supporting a broad scope of functionalities that are related to the old C language and C++ does not duplicate the functionality of the standard C library, it uses the standard C library for many common functions like:
- the C String library < cstring >
- the C Math library < cmath >
You can note that it always starts with c, and you can find the full list in the cplusplus reference here C library. Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the .h, and adding a 'c' at the start; for example, 'time.h' becomes 'ctime'.
#include // the C header version.
#include // the C++ version.
C++ STL
C++ added its own library which depends on Templates and called it STL or Standard Template Library, It consists of many components and utilities, the components can be split into three types:
- Containers
- Iterators
- Algorithms
Containers
They are template classes that can be used to manipulate the data in a standard way, and they are two categories:
- Sequential Containers
- Associative Containers