Files
2025-10-25 03:02:53 +03:00

4.9 KiB
Raw Permalink Blame History

[meta.logical]

21 Metaprogramming library [meta]

21.3 Metaprogramming and type traits [type.traits]

21.3.10 Logical operator traits [meta.logical]

1

#

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

🔗

template<class... B> struct conjunction : see below { };

2

#

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

3

#

For a specialization conjunction<B1, …, BN>, if there is a template type argument Bi for which bool(Bi::value) is false, then instantiating conjunction<B1, …, BN>::value does not require the instantiation of Bj::value for j>i.

[Note 1:

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

— end note]

4

#

Every template type argument for which Bi::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.

5

#

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

the first type Bi in the list true_type, B1, …, BN for which bool(Bi::value) is false, or

if there is no such Bi, the last type in the list.

[Note 2:

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

— end note]

6

#

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 { };

7

#

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

8

#

For a specialization disjunction<B1, …, BN>, if there is a template type argument Bi for which bool(Bi::value) is true, then instantiating disjunction<B1, …, BN>::value does not require the instantiation of Bj::value for j>i.

[Note 3:

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

— end note]

9

#

Every template type argument for which Bi::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.

10

#

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

the first type Bi in the list false_type, B1, …, BN for which bool(Bi::value) is true, or

if there is no such Bi, the last type in the list.

[Note 4:

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

— end note]

11

#

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 { };

12

#

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

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