BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_booleantestable

Outline

Purpose

Provide an exposition-only concept boolean-testable.

Classes

Description

This component provides a concept, bslmf::BooleanTestable, that specifies the requirements on expressions that are convertible to bool and for which the logical operators have the conventional semantics. For more details, please refer to [concept.booleantestable] in the ISO C++20 Standard.

Usage

This section illustrates intended use of this component.

Example 1: Implementing a Concept for a Predicate (Boolean) Expression

In the following example we use bslmf::BooleanTestable to implement a concept to determine whether applying the < operator to a given type produces an if-testable result.

template <class t_TYPE>
concept LessComparable =
requires(t_TYPE v) {
{ v < v } -> bslmf::BooleanTestable;
};

Now types can be tested using this concept:

static_assert(LessComparable<int>);
struct NonLessComparable { void operator<(NonLessComparable) {} };
static_assert(!LessComparable<NonLessComparable>);