命名空间
变体
操作

标准库头文件 <ciso646> (直到 C++20), <iso646.h>

来自 cppreference.cn
< cpp‎ | header
 
 
标准库头文件
算法
<algorithm>
<numeric>
字符串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文本处理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
数值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
时间
<chrono> (C++11)
<ctime>
C 兼容性
<ccomplex> (C++11/17/20*)
<ciso646> (直到 C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此头文件最初在 C 标准库中为 <iso646.h>

兼容性头文件,在 C 中定义了 备选运算符表示,它们在 C++ 中是关键字。

这意味着在符合规范的实现中,包含此头文件没有任何效果。

[编辑] 注释

在旧的或不符合规范的编译器中,使用 备选运算符表示 可能仍然需要包含此头文件。

<ciso646> 在 C++20 中被移除。对应的 <iso646.h> 在 C++20 中仍然可用。

在 C++20 之前,包含 <ciso646> 有时被用作获取特定于实现的库版本宏定义的技术,而不会引起其他效果。 从 C++20 开始,添加了头文件 <version> 以达到此目的。

#include <ciso646>
#ifdef _LIBCPP_VERSION
#error Using LLVM libc++
#elif __GLIBCXX__ // Note: only version 6.1 or newer define this in ciso646
#error Using GNU libstdc++
#elif _CPPLIB_VER // Note: used by Visual Studio
#error Using Microsoft STL
#else
#error Using an unknown standard library
#endif

可能的输出

main.cpp:7:2: error: Using Microsoft STL
#error Using Microsoft STL
 ^
1 error generated.