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
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
