名稱空間
變體
操作

標準庫標頭檔案 <ciso646> (C++20 前), <iso646.h>

來自 cppreference.com
 
 
標準庫標頭檔案
演算法
<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.