std:: negation
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<type_traits>
|
||
|
template
<
class
B
>
struct negation ; |
(C++17 起) | |
形成类型特征 B 的 逻辑非 运算。
类型 std :: negation < B > 是一个 一元类型特性 ,其基础特征为 std:: bool_constant < ! bool ( B :: value ) > 。
如果程序为
std::negation
或
std::negation_v
添加特化,则行为是未定义的。
目录 |
模板参数
| B | - | 满足表达式 bool ( B :: value ) 为合法常量表达式的任意类型 |
辅助变量模板
|
template
<
class
B
>
constexpr bool negation_v = negation < B > :: value ; |
(C++17 起) | |
继承自 std:: integral_constant
成员常量
|
value
[static]
|
若
B
拥有成员
::
value
且在显式转换为
bool
时为
false
则值为
true
,否则为
false
(公开静态成员常量) |
成员函数
|
operator bool
|
将对象转换为
bool
,返回
value
(公开成员函数) |
|
operator()
(C++14)
|
返回
value
(公开成员函数) |
成员类型
| 类型 | 定义 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
可能的实现
template<class B> struct negation : std::bool_constant<!bool(B::value)> { }; |
注释
| 功能测试 宏 | 值 | 标准 | 功能 |
|---|---|---|---|
__cpp_lib_logical_traits
|
201510L
|
(C++17) | 逻辑运算符类型特征 |
示例
#include <type_traits> static_assert( std::is_same< std::bool_constant<false>, typename std::negation<std::bool_constant<true>>::type>::value, ""); static_assert( std::is_same< std::bool_constant<true>, typename std::negation<std::bool_constant<false>>::type>::value, ""); static_assert(std::negation_v<std::bool_constant<true>> == false); static_assert(std::negation_v<std::bool_constant<false>> == true); int main() {}
参见
|
(C++17)
|
变参逻辑与元函数
(类模板) |
|
(C++17)
|
变参逻辑或元函数
(类模板) |
|
(C++11)
(C++17)
|
具有指定值和指定类型的编译期常量
(类模板) |