[concept.booleantestable] (original) (raw)

18 Concepts library [concepts]

18.5 Comparison concepts [concepts.compare]

18.5.2 Boolean testability [concept.booleantestable]

Let e be an expression such thatdecltype((e)) is T.

T models boolean-testable-impl only if

A disqualifying parameteris a function parameter whose declared type P

A key parameter of a function template Dis a function parameter of type cv X or reference thereto, where X names a specialization of a class template that has the same innermost enclosing non-inline namespace as D, andX contains at least one template parameter that participates in template argument deduction.

[Example 1:

Innamespace Z { template<class> struct C {};template<class T> void operator&&(C<T> x, T y);template<class T> void operator||(C<type_identity_t<T>> x, T y);} the declaration of Z​::​operator&&contains one key parameter, C<T> x, and the declaration of Z​::​operator||contains no key parameters.

— _end example_]

A disqualifying declaration is

[Note 1:

The intention is to ensure that given two types T1 and T2that each model boolean-testable-impl, the && and || operators within the expressionsdeclval<T1>() && declval<T2>() anddeclval<T1>() || declval<T2>()resolve to the corresponding built-in operators.

— _end note_]

template<class T> concept [_boolean-testable_](#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]") = // _exposition only_ [_boolean-testable-impl_](#concept:boolean-testable-impl "18.5.2 Boolean testability [concept.booleantestable]")<T> && requires(T&& t) { { !std::forward<T>(t) } -> [_boolean-testable-impl_](#concept:boolean-testable-impl "18.5.2 Boolean testability [concept.booleantestable]");};

Let e be an expression such thatdecltype((e)) is T.

T models boolean-testable only ifbool(e) == !bool(!e).

[Example 2:

— _end example_]