std::negation

Header: <type_traits>

Forms the logical negation of the type trait B.

# Declarations

template< class B >
struct negation;

(since C++17)

# Notes

Feature-test macro Value Std Feature __cpp_lib_logical_traits 201510L (C++17) Logical operator type traits

# Example

#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() {}

# See also