Checking for availability of C++0x algorithm additions(检查 C++0x 算法添加的可用性)
问题描述
我正在尝试找出给定实现支持对算法头的哪些添加(gcc 和 MSVC 就足够了).
I'm trying to figure out which of the additions to the algorithm headers are supported by a given implementation (gcc and MSVC would be enough).
最简单的方法是使用与核心功能相同的方法:检查编译器版本并在支持语言功能时定义宏.不幸的是,我找不到显示任一编译器版本号的列表.
The simple way would be to do it the same way as one would do it for core features: check the compiler version and define a macro if a language feature is supported. Unfortunately I cannot find a list that shows the version numbers for either compiler.
只是检查通用 C++0x 宏(GXX_EXPERIMENTAL 或 __cplusplus)就足够了,还是我应该检查编译器的更改列表并根据这些列表构建我的宏?
Is simply checking for a generic C++0x macro (GXX_EXPERIMENTAL or __cplusplus) enough or should I check the change lists for the compilers and build my macros based on those lists?
http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x
推荐答案
由于所有编译器供应商都提供了一个很好的列表,列出了哪些版本可用,并且无论如何您都会测试功能,所以我会使用编译器版本来检查特定功能.或者要求用户至少使用一个好的版本,而不用担心它.
Since all compiler vendors provide a nice list of what's available in what version, and you would test the functionality anyways, I would use compiler versions to check for specific features. Or demand the user uses at least a good version, and not worry about it.
__cplusplus
不一定是 C++0x 宏,它什么也不告诉你.GXX_EXPERIMENTAL
从 GCC 4.3 开始就存在了,所以这也没什么用.
__cplusplus
is not necessarily a C++0x macro, it tells you nothing. GXX_EXPERIMENTAL
has existed since GCC 4.3, so that's pretty useless too.
这是 GCC 的.
这个是给 MSVC 的.(请注意:部分实施意味着损坏)
This one is for MSVC. (mind you: partially implemented means broken)
这个适用于英特尔.
这里您可以找到要检查特定编译器版本的宏.
Here you can find what macros to check against for a specific version of a compiler.
这篇关于检查 C++0x 算法添加的可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检查 C++0x 算法添加的可用性
- C++ 协变模板 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 近似搜索的工作原理 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 静态初始化顺序失败 2022-01-01