std::bit_and
來自 cppreference.com
定義於標頭檔案 <functional> |
||
template< class T > struct bit_and; |
(直到 C++14) | |
template< class T = void > struct bit_and; |
(C++14 起) | |
用於執行位 AND 運算的函式物件。實際上呼叫型別 T
上的 operator&。
目錄 |
[編輯] 特化
標準庫提供了
|
(C++14 起) |
[編輯] 成員型別
型別 | 定義 |
result_type (C++17 中已棄用)(C++20 中已移除) |
T
|
first_argument_type (C++17 中已棄用)(C++20 中已移除) |
T
|
second_argument_type (C++17 中已棄用)(C++20 中已移除) |
T
|
這些成員型別是透過公開繼承 std::binary_function<T, T, T> 獲得的。 |
(C++11 前) |
[編輯] 成員函式
operator() |
返回兩個引數的位 AND 運算結果 (公開成員函式) |
std::bit_and::operator()
T operator()( const T& lhs, const T& rhs ) const; |
(C++14 起為 constexpr) | |
返回 lhs 和 rhs 的位 AND 運算結果。
引數
lhs, rhs | - | 進行位 AND 運算的值 |
返回值
lhs & rhs 的結果。
[編輯] 異常
可能丟擲實現定義的異常。
可能的實現
constexpr T operator()(const T& lhs, const T& rhs) const { return lhs & rhs; } |
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 660 | C++98 | 缺少位運算的函式物件 | 已新增 |