Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/types/negation"

From cppreference.com
< cpp‎ | types
(LWG 2567)
(Helper variable template: adjust)
Line 26: Line 26:
 
{{dcl end}}
 
{{dcl end}}
  
{{cpp/types/integral_constant/inherit | {{tt|B}} has a member {{tt|::value}} that is {{c|false}} }}
+
{{cpp/types/integral_constant/inherit | {{tt|B}} has a member {{tt|::value}} that is {{c|false}} when explicitly converted to {{tt|bool}} }}
  
 
===Possible implementation===
 
===Possible implementation===

Revision as of 22:20, 16 November 2016

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
Defined in header <type_traits>
template<class B>
struct negation;
(1) (since C++17)

Forms the logical negation of the type trait B.

The type std::negation<B> is a Template:concept with a BaseCharacteristic of std::bool_constant<!bool(B::value)>.

Contents

Template parameters

B - any type such that B::value is convertible to bool

Helper variable template

template<class B>
constexpr bool negation_v = negation<B>::value;
(since C++17)

Inherited from std::integral_constant

Member constants

value
[static]
true if B has a member ::value that is false when explicitly converted to bool , false otherwise
(public static member constant)

Member functions

operator bool
converts the object to bool, returns value
(public member function)
operator()
(C++14)
returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>

Possible implementation

template<class B>
struct negation : std::bool_constant<!B::value> { };

Example

See also

variadic logical AND metafunction
(class template) [edit]
variadic logical OR metafunction
(class template) [edit]