18 Concepts library [concepts]

18.5 Comparison concepts [concepts.compare]

18.5.2 Concept boolean [concept.boolean]

The boolean concept specifies the requirements on a type that is usable as a truth value.
template<class B> concept boolean = movable<remove_cvref_t<B>> && // (see [concepts.object]) requires(const remove_reference_t<B>& b1, const remove_reference_t<B>& b2, const bool a) { { b1 } -> convertible_to<bool>; { !b1 } -> convertible_to<bool>; { b1 && b2 } -> same_as<bool>; { b1 && a } -> same_as<bool>; { a && b2 } -> same_as<bool>; { b1 || b2 } -> same_as<bool>; { b1 || a } -> same_as<bool>; { a || b2 } -> same_as<bool>; { b1 == b2 } -> convertible_to<bool>; { b1 == a } -> convertible_to<bool>; { a == b2 } -> convertible_to<bool>; { b1 != b2 } -> convertible_to<bool>; { b1 != a } -> convertible_to<bool>; { a != b2 } -> convertible_to<bool>; };
For some type B, let b1 and b2 be lvalues of type const remove_­reference_­t<B>.
B models boolean only if
Example
:
The types bool, true_­type ([meta.type.synop]), and bitset<N>​::​reference ([template.bitset]) are boolean types.
Pointers, smart pointers, and types with only explicit conversions to bool are not boolean types.
— end example
 ]