[meta.logical] (original) (raw)

21 Metaprogramming library [meta]

21.3 Metaprogramming and type traits [type.traits]

21.3.9 Logical operator traits [meta.logical]

This subclause describes type traits for applying logical operators to other type traits.

template<class... B> struct conjunction : _see below_ { };

The class template conjunctionforms the logical conjunction of its template type arguments.

For a specialization conjunction<, …, >, if there is a template type argument for which bool(​::​value) is false, then instantiating conjunction<, …, >​::​valuedoes not require the instantiation of ​::​value for .

[Note 1:

This is analogous to the short-circuiting behavior of the built-in operator &&.

— _end note_]

Every template type argument for which ​::​value is instantiated shall be usable as a base class and shall have a member value which is convertible to bool, is not hidden, and is unambiguously available in the type.

The specialization conjunction<, …, >has a public and unambiguous base that is either

[Note 2:

This means a specialization of conjunctiondoes not necessarily inherit from either true_type or false_type.

— _end note_]

The member names of the base class, other than conjunction andoperator=, shall not be hidden and shall be unambiguously available in conjunction.

template<class... B> struct disjunction : _see below_ { };

The class template disjunctionforms the logical disjunction of its template type arguments.

For a specialization disjunction<, …, >, if there is a template type argument for which bool(​::​value) is true, then instantiating disjunction<, …, >​::​valuedoes not require the instantiation of ​::​value for .

[Note 3:

This is analogous to the short-circuiting behavior of the built-in operator ||.

— _end note_]

Every template type argument for which ​::​value is instantiated shall be usable as a base class and shall have a member value which is convertible to bool, is not hidden, and is unambiguously available in the type.

The specialization disjunction<, …, >has a public and unambiguous base that is either

[Note 4:

This means a specialization of disjunctiondoes not necessarily inherit from either true_type or false_type.

— _end note_]

The member names of the base class, other than disjunction and operator=, shall not be hidden and shall be unambiguously available in disjunction.

template<class B> struct negation : _see below_ { };

The class template negationforms the logical negation of its template type argument.

The type negation<B>is a Cpp17UnaryTypeTrait with a base characteristic of bool_constant<!bool(B​::​​value)>.