std::experimental::ranges::Boolean

From cppreference.com
< cpp‎ | experimental‎ | ranges
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
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)

The concept Boolean<B> specifies the requirements for a type usable in Boolean contexts. For Boolean

Boolean<B> is satisfied only if:

  • bool (b1) == ! bool ( !b1)
  • b1 && b2, b1 && bool(b2) and bool(b1) && b2 are all equal to bool(b1) && bool(b2)
  • b1 || b2, b1 || bool(b2) and bool(b1) || b2 are all equal to bool(b1) || bool(b2)
  • bool(b1 == b2), bool(b1 == bool(b2)) , and bool(bool(b1) == b2) are all equal to ( bool (b1) == bool (b2) )
  • bool(b1 != b2), bool (b1 ! = bool (b2) ) , and bool ( bool (b1) ! = b2) are all equal to ( bool (b1) ! = bool (b2) )

Equality preservation

An expression is equality preserving if it results in equal outputs given equal inputs.

  • The inputs to an expression consist of its operands.
  • The outputs of an expression consist of its result and all operands modified by the expression (if any).

Every expression required to be equality preserving is further required to be stable

Unless noted otherwise, every expression used in a requires-expression

Implicit expression variations

A requires-expression implicit expression variations

Notes

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

A deduction constraint of the form { expression } - > Same<T> && effectively requires decltype((expression))&& to be the exact same type as T&&