我可以在 g++ 中使用可变参数模板(但不能使用其他 c++0x 功能)吗?

发布于 2024-12-05 02:30:49 字数 280 浏览 0 评论 0原文

我们的想法是,由于可变参数模板是编译时功能,因此 ABI 影响或运行时行为变化很小。这可能吗?

我特别希望 boost::mpl::vector 和 boost::mpl::string 的编译时间更快。

重新表述问题...

是否可以通过将 c++03 和 c++11 代码分离到库中来混合它们?也就是说,我们使用了很多与 gcc 4.3 兼容的第三方 c++ 库,但我们也正在转向 gcc 4.7,并打算在可能/有意义的情况下使用 c++11 功能。或者说c++11和c++03不可能混合使用吗?

The thinking is that since variadic templates are a compile time feature, there will be little ABI impact or runtime behaviour change. Is this possible?

I specifically want the benefit of faster compile times for boost::mpl::vector and boost::mpl::string.

Rephrasing the question...

Is it possible to mix c++03 and c++11 code by separating them into libraries? I.e. we use quite a few 3rd party c++ libraries which are compatible with gcc 4.3 but we are moving on too gcc 4.7 and intend to use c++11 features where possible/makes sense. Or is it impossible to mix c++11 and c++03?

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

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

发布评论

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

评论(2

浪荡不羁 2024-12-12 02:30:49

您应该使用在兼容模式下运行的相同工具来编译和链接所有内容。你不能挑选这样的功能。

例如,ABI 的影响体现在标准 I/O 类的虚拟功能表的增加。混用东西是安全的。

You should compile and link everything using the same tools running in compatible modes. You can't cherry-pick features like this.

The ABI impact comes in, for example, increased virtual function tables for standard I/O classes. It is not safe to mix things around.

乜一 2024-12-12 02:30:49

我无法给出合格的答案,但据我了解,很多人会担心这种向后兼容性是否会被破坏。据我了解,新的 C++11 中没有任何内容需要重建所有内容。因此,只有您的特定编译器才需要这样做。对于 GCC,我不期望它,但不同的 libstdc++ 版本可能会产生“问题”。

我强烈的猜测是,在典型的(英特尔)Linux 上,您应该能够使用不同的新版本的 gcc(可能> 4.x)创建两个独立的库,并将它们使用/链接到最终程序中。不过,有些东西可能会出现两次。我在 4.7.0 和 中遇到了一些可解决的小问题。我不知道他们是否会与其他线程库(例如 boost)创建一个好的或坏的组合。但是,您还不想在生产代码中使用 gcc-4.7.0。在最终的 gcc 编译器发布之前,只有负责项目团队的声明才能给您确定性。

I cant give a qualified answer, but from what I understood is, that lots of people would be concerned if this kind of backward-compatibility would be broken. As far as I understood there is nothing in the new C++11 that makes it necessary to rebuild everything. Thus, it could only be your specific compiler that would make that necessary. For the GCC I dont't expect it, although, the different libstdc++ versions could create "issues".

My strong guess is, that on a typical (intel-) linuxes you should be able to create two independent libs with different decently new versions of the gcc (maybe >4.x) and use/link them into a final program. You may have some things in there twice, though. I had some minor solvable issues with threads in 4.7.0 and <thread>. I don't know if they would create a good or bad mix with other thread-libs (eg. boost). However, you don't want to use gcc-4.7.0 for your production code, yet. And before a final gcc compiler is out, only a statement from the responsible projects team can give you certainty.

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