std::negation(3)
π
std::negation(3) β from the C++ Standard Libary π
β¨ NAME β¨
std::negation β std::negation. Thatβs literally the name, bestie, no cap. Itβs the C++ Standard Libary page for std::negation.
πΈ Synopsis πΈ
Defined in header <type_traits>
template< class B > (since C++17)
struct negation;
okay so std::negation forms the logical negation of the type trait B π
The type std::negation<B> is a UnaryTypeTrait with a base characteristic of std::bool_constant<!bool(B::value)>.
π¨ bestie, important: if the program adds specializations forstd::negationorstd::negation_v, the behavior is undefined. not cute, not iconic, just undefined π
π¦ Template parameters π¦
Bβ any type such that the expressionbool(B::value)is a valid constant expression.
π Helper variable template π
template< class B > (since C++17)
inline constexpr bool negation_v = negation<B>::value;
π«Ά Inherited from std::integral_constant π«Ά
π Member constants π
valueβtrueifBhas a member::valuethat isfalsewhen explicitly converted to[static] bool,falseotherwise (public static member constant).
π Member functions π
operator boolβ converts the object tobool, returnsvalue(public member function).operator()β returnsvalue(C++14) (public member function).
π Member types π
value_typeβbooltypeβstd::integral_constant<bool, value>
β¨ Possible implementation β¨
template<class B>
struct negation : std::bool_constant<!bool(B::value)> { };
π Notes π
- Feature-test macro:
__cpp_lib_logical_traitsβ Value:201510Lβ Std: (C++17) β Feature: Logical operator type traits
π» Example π»
Run this code, bestie:
// Run this code
#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';
}
π€ Output π€
false
true
π See also π
conjunctionβ variadic logical AND metafunction (C++17) (class template)disjunctionβ variadic logical OR metafunction (C++17) (class template)integral_constantβ (C++11) (class template)bool_constantβ compile-time constant of specified type with specified value (C++17) (class template)
okay bestie, thatβs the whole page π source: http://cppreference.com, version/date stamp: 2024.06.10, and this is std::negation(3) signing off πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms