std::experimental::ranges::Boolean

Header: <experimental/ranges/concepts>

The concept Boolean specifies the requirements for a type usable in Boolean contexts. For Boolean to be satisfied, the logical operators must have the usual behavior (including short-circuiting). More precisely, given

# Declarations

template< class B >
concept bool Boolean =
Movable<std::decay_t<B>> &&
requires(const std::remove_reference_t<B>& b1,
const std::remove_reference_t<B>& b2, const bool a) {
{ b1 } -> ConvertibleTo<bool>&&;
{ !b1 } -> ConvertibleTo<bool>&&;
{ b1 && a } -> Same<bool>&&;
{ b1 || a } -> Same<bool>&&;
{ b1 && b2 } -> Same<bool>&&;
{ a && b2 } -> Same<bool>&&;
{ b1 || b2 } -> Same<bool>&&;
{ a || b2 } -> Same<bool>&&;
{ b1 == b2 } -> ConvertibleTo<bool>&&;
{ b1 == a } -> ConvertibleTo<bool>&&;
{ a == b2 } -> ConvertibleTo<bool>&&;
{ b1 != b2 } -> ConvertibleTo<bool>&&;
{ b1 != a } -> ConvertibleTo<bool>&&;
{ a != b2 } -> ConvertibleTo<bool>&&;
};

(ranges TS)

# Notes

Examples of Boolean types include bool, std::true_type, and std::bitset::reference. Pointers are not Boolean types.

A deduction constraint of the form { expression } -> Same&& effectively requires decltype((expression))&& to be the exact same type as T&&. This constrains both the expression’s type and its value category.