std::bit_xor
来自cppreference.com
< cpp | utility | functional
在标头 <functional> 定义 | ||
template<class T > struct bit_xor; | (C++14 前) | |
template<class T =void> struct bit_xor; | (C++14 起) | |
进行逐位异或的函数对象。相当于调用类型 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() | 返回两个实参逐位异或的结果 (公开成员函数) |
std::bit_xor::operator()
T operator()(const T& lhs, const T& rhs )const; | (C++14 起为 constexpr ) | |
返回 lhs 与 rhs 逐位异或的结果。
参数
lhs, rhs | - | 要计算逐位异或的值 |
返回值
lhs ^ rhs 的结果。
[编辑]异常
可能会抛出由实现定义的异常。
可能的实现
constexpr T operator()(const T& lhs, const T& rhs)const{return lhs ^ rhs;} |
[编辑]缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 660 | C++98 | 缺少逐位运算的函数对象 | 已添加 |