通用库是否包含普通用户无法编写的代码?

发布于 2024-11-15 19:17:46 字数 158 浏览 1 评论 0原文

boost、STL、ACE(通常包含在命名空间 std 中)等库是否包含任何特殊类型的编码技术,而这些技术不可能由普通程序员?

从更广泛的意义上来说,他们是否利用任何编译器或实现特定的实用程序,这些实用程序不向一般程序员公开?

Do libraries such as boost, STL, ACE (which often make inclusions in namespace std) contain any special kind of coding techniques which is not possible to be coded/used by a usual programmer ?

In a broader sense, do they leverage any compiler or implementation specific utilities, which is not exposed to the general programmers ?

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

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

发布评论

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

评论(3

×纯※雪 2024-11-22 19:17:46

这些都是用每个人都可以使用的相同代码编写的。然而,代码通常很难阅读(至少对我来说),因为它们竭尽全力确保库的通用性。 这里是STL的sgi实现。浏览一下并亲自看看。

These are all written in the same code available to everyone. However, the code is often hard to read (at least for me) because they go to great lengths to ensure the generality of the libraries. Here is the sgi implementation of the STL. Browse through it and see for yourself.

韬韬不绝 2024-11-22 19:17:46

由于标准库是 C++ 规范的一部分,因此您的问题没有充分依据。

例如,std::fstream(或至少std::filebuf)的实现必须使用依赖于操作系统的接口。这些算作“特定于实现的实用程序”吗?

最重要的是,规范没有将标准库与语言的其余部分分开。它只是语言的一部分,其功能可供“普通程序员”使用。

Boost 大部分是用标准 C++ 编写的,但它们确实利用了平台特定的功能,可以提高性能,并且偶尔需要依赖于编译器的功能扩展。文档通常会提到某些功能并非在所有平台上都可用。

我不知道ACE。

Since the standard library is part of the C++ specification, your question is not well-founded.

For example, the implementation of std::fstream (or at least, std::filebuf) must use OS-dependent interfaces. Do those count as "implementation specific utilities"?

The bottom line is that the spec does not separate out the standard library from the rest of the language. It is all just part of the language, and its facilities are available to "usual programmers".

Boost is mostly written in standard C++, but they do take advantage of platform-specific features when that can yield performance improvements, and they occasionally need compiler-dependent extensions for features. The documentation will generally mention when a feature is not available on all platforms.

I do not know about ACE.

掩于岁月 2024-11-22 19:17:46

STL(和其他)是用“纯C++”编写的。请参阅此处了解非常类似的问题。

另一方面,C 在其标准库文件中有许多系统调用(unix/Windows/etc)以使一切正常工作。

C++0x STL 还使用了一些编译器魔法来使一些新的语言功能发挥作用。

The STL (and the others) is written in 'pure C++'. See here for a very similar question.

C, on the other hand, has many system calls (unix/Windows/etc) in its standard library files to make everything work.

The C++0x STL also uses some compiler magic to make some new language features work.

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