Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the design principle of c++ standard library? [closed]

So the standard c++ library mainly contains roughly 7 categories,

what's the rationale/prototype that make it deserve being the standard?

BTW,which category does socket programing related stuff belong to in the c++ standard library?

like image 541
Je Rog Avatar asked Feb 23 '23 18:02

Je Rog


2 Answers

I don't know that it makes much sense to say that the C++ standard library has a single unifying design principle (perhaps object oriented programming, orthogonality, or type covariance?), but it does have some technical design goals. According to Bjarne Stroustrup (quoted from the C++ programming language, page 429-430), the STL does the following:

  1. Provides support for language features, such as memory management and run-time type information.

  2. Supplies information about implementation-defined aspects of the language, such as the largest float value.

  3. Supplies functions that cannot be implemented optimally in the language itself for every system, such as sqrt() and memmove().

  4. Supplies nonprimitive facilities that a programmer can rely on for portability, such as lists, maps, sort functions, and I/O streams.

  5. Provides a framework for extending the facilities it provides, such as conventions and support facilities that allow a user to provide I/O of a user-defined type in the style of I/O for built-in types.

  6. Provides the common foundation for other libraries.

like image 131
Mikola Avatar answered Mar 03 '23 12:03

Mikola


what's the rationale/prototype that make it deserve being the standard?

The same rationale/prototype that made C++98 a standard.

In the 90's, a lot of compiler writers were poking with extensions to C. These usually involved adding object-oriented features to C (hence the term "C with Classes"). This was the early days of the internet, and many people involved with compiler writing and language extensions started standardizing things.

The standard library was part of that process. Iostreams came from certain developers. The reason that much of the standard library is called "STL" is because the Standard Template Library was a widely distributed proto-C++ library based on a new feature making the rounds in C++ compilers: templates.

Eventually, an ISO committee decided to get together and form a real standard. They took all the bits that people called "C++", ironed out a few incompatibilities (iostreams became templated on the character type, though they forgot some things there), and eventually agreed on the ISO standard.


As for "socket programming," that's not part of the C++ standard library. Therefore it does not belong in any of those categories.

The only reason those categories exist is because that's what is in the standard library. C++0x will add more categories (threads is a big one).

like image 29
Nicol Bolas Avatar answered Mar 03 '23 12:03

Nicol Bolas