c++的设计原理是什么?标准库?

发布于 2024-11-17 05:16:33 字数 207 浏览 4 评论 0原文

所以标准c++库主要包含大约7类别,

使它值得成为标准的基本原理/原型是什么?

顺便说一句,套接字编程相关的东西在c++标准库中属于哪个类别?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始终不够爱げ你 2024-11-24 05:16:33

我不知道说 C++ 标准库具有单一的统一设计原则(也许是面向对象编程、正交性或类型协变?)有多大意义,但它确实有一些技术设计目标。根据 Bjarne Stroustrup 的说法(引自 C++ 编程语言,第 429-430 页),STL 执行以下操作:

  1. 提供对语言功能的支持,例如内存管理和运行时类型信息。

  2. 提供有关语言的实现定义方面的信息,例如
    最大浮点值。

  3. 为每个系统提供语言本身无法最佳实现的函数,例如 sqrt() 和 memmove()。

  4. 提供程序员可以依赖的非原始设施来实现可移植性,例如列表、映射、排序函数和 I/O 流。

  5. 提供一个框架来扩展它所提供的功能,例如允许用户以内置类型的 I/O 风格提供用户定义类型的 I/O 的约定和支持功能。

  6. 为其他库提供共同基础。

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.

寂寞陪衬 2024-11-24 05:16:33

使它值得成为标准的基本原理/原型是什么?

使 C++98 成为标准的基本原理/原型相同。

在 90 年代,许多编译器编写者都在研究 C 的扩展。这些通常涉及向 C 添加面向对象的功能(因此称为“C with Classes”)。这是互联网的早期阶段,许多参与编译器编写和语言扩展的人开始标准化事物。

标准库是该过程的一部分。 Iostreams 来自某些开发人员。标准库的大部分内容被称为“STL”的原因是因为标准模板库是一个广泛分布的原始 C++ 库,基于 C++ 编译器中流行的新功能:模板。

最终,ISO 委员会决定联合起来制定一个真正的标准。他们采用了人们称为“C++”的所有部分,解决了一些不兼容性(iostreams 成为字符类型的模板,尽管他们忘记了那里的一些东西),并最终同意了 ISO 标准。


至于“套接字编程”,它不属于 C++ 标准库的一部分。因此它不属于任何这些类别。

这些类别存在的唯一原因是因为这是标准库中的内容。 C++0x会增加更多的类别(线程是一大类)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文