C++: Difference between revisions

331 bytes added ,  7 years ago
→‎Standard Template Library: Remove blantantly wrong STL usage and claims
[unchecked revision][unchecked revision]
m (Fix access to one element past the end of the array.)
(→‎Standard Template Library: Remove blantantly wrong STL usage and claims)
Line 481:
See [[C++ Exception Support]].
 
== Standard Template Library ==
Note that the C++ Standard Library (stdlib) is not the same as the C++ Standard Template Library (STL). The STL was designed in 1994 and largely influenced the C++ Standard Library, but it's not a part of the ISO C++ standard. The C++ Standard Library is part of the C++ ISO specification, however, and is what you're using when you use ''std::vector'', ''std::string'', etc. Be wary of misusing the term STL and, ideally, avoid it completely. Anyone using it almost certainly means the C++ stdlib.
You cannot use STL ([[Standard Template Library]]) functions or classes without porting an STL implementation. Note that C++ classes and templates (e.g. std::vector, std::string) actually aren't part of the C++ language. They are part of a library called the Standard Template Library. A lot of the code depending on STL is OS-dependent, so you must port an STL implementation to your OS if you want to use them.
 
You cannot use STL ([[Standard Template Library]])stdlib functions or classes without porting ana STLstdlib implementation. Note that C++ classes and templates (e.g. std::vector, std::string) actually aren't part of the C++ language. They are part of a library called the Standard Template Library. A lot of theexisting code depending on STLthe stdlib is OS-dependent, so you must port an STLstdlib implementation to your OS if you want to use them.
To gain access to the STL in your OS you can do either of the following:
* Write your own implementation of a few of the required templates classes (std::string, std::list, std::cout, ...).
* Port an STL implementation to your OS (e.g. [[STLport]]).
 
To gain access to the STLstdlib in your OS you can do either of the following:
A lot of the STL classes require '''new''' and '''delete''' to be implemented in your OS. File access requires your OS to support reading and wrapping. Console functions require your OS to already have working console I/O.
* Write your own implementation of a few of the required templatesclass classestemplates (std::string, std::list, std::cout, ...).
* Port ana STLstdlib implementation to your OS (e.g. [[STLport]]).
 
A lot of the STLstdlib classes require '''new''' and '''delete''' to be implemented in your OS. File access requires your OS to support reading and wrapping. Console functions require your OS to already have working console I/O.
Porting the STL (like porting the [[C Standard Library]]) does not automatically make your OS able to read from and write to the disk or get data straight from the keyboard. These are simply wrappers around your OS' functions, and must be implemented by in your kernel.
 
Porting the STLC++ stdlib (like porting the [[C Standard Library]]) does not automatically make your OS able to read from and write to the disk or get data straight from the keyboard. These are simply wrappers around your OS' functions, and must be implemented by in your kernel.
Note that it is generally not a good idea to port the entire STL to your kernel, although it is reasonable to port a few classes, such as <tt>std::vector</tt> and <tt>std::string</tt> if you wish to. As for your user applications: the more the merrier! :)
 
Note that it is generally not a good idea to port the entire STLstdlib to your kernel, although it is reasonable to port a few classesclass templates, such as <tt>std::vector</tt> and <tt>std::string</tt> if you wish to. As for your user applications: the more the merrier! :)
Here is a list of a the most commonly used STL implementations:
 
Here is a list of a the most commonly used STLstdlib implementations:
 
* [http://incubator.apache.org/stdcxx/ STDCXX] (a.k.a Apache C++ Standard Library, formally Rogue Wave C++ Standard Library)
Anonymous user