std::negation
| Defined in header <type_traits> |  |  | 
|---|---|---|
| template<class B> struct negation; | (1) | (since C++17) | 
形成类型特征的逻辑否定B...
类型std::negation<B>是UnaryTypeTrait基本特征std::bool_constant<!bool(B::value)>...
模板参数
| B | - | any type such that B::value is convertible to bool | 
|---|
辅助变量模板
| template<class B> inline constexpr bool negation_v = negation<B>::value; |  | (since C++17) | 
|---|
继承自STD:积分[医]常量
成员常数
| value static | true if B has a member ::value that is false when explicitly converted to bool , false otherwise (public static member constant) | 
|---|
成员函数
| operator bool | converts the object to bool, returns value (public member function) | 
|---|---|
| operator() (C++14) | returns value (public member function) | 
成员类型
| Type | Definition | 
|---|---|
| value_type | bool | 
| type | std::integral_constant<bool, value> | 
可能的实施
模板<class B>结构否定:STD::Bool[医]常数<%21B::value>{};
*。
例
二次
#include <iostream>
#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,
    "");
 
int main()
{
    std::cout << std::boolalpha;
    std::cout << std::negation<std::bool_constant<true>>::value << '\n';
    std::cout << std::negation<std::bool_constant<false>>::value << '\n';
}二次
产出:
二次
false
true二次
另见
| conjunction (C++17) | variadic logical AND metafunction (class template) | 
|---|---|
| disjunction (C++17) | variadic logical OR metafunction (class template) | 
| integral_constantbool_constant (C++11)(C++17) | compile-time constant of specified type with specified value (class template) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

