A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../named_req/BooleanTestable.html below:

C++ named requirements: BooleanTestable - cppreference.com

Specifies that an expression of such a type and value category is convertible to bool, and for which the logical operators for the type or two different BooleanTestable types have the usual behavior (including short-circuiting).

[edit] Requirements

Let e be an expression of a certain type and value category. The type and value category meet the BooleanTestable requirements if:

[edit] Notes

The standard does not define a named requirement with this name. It was originally proposed in an early resolution of LWG2114, but was superseded by the exposition-only concept boolean-testable in the final resolution P2167R3. Because implementations generally expect the provided types to model boolean-testable even in pre-C++20 modes, we intentedly treat P2167R3 as a defect report and transform the boolean-testable to legacy named requirements.

When the && and || operators are used with operands whose type and value category are BooleanTestable, built-in versions are selected and short-circuit evaluation is performed.

The type and value category of an expression e meet the BooleanTestable requirements if and only if decltype((e)) models boolean-testable.

(since C++20)

Examples of BooleanTestable types (with any value category) include bool, std::true_type(since C++11), std::bitset<N>::reference, and int*.

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 2114
(P2167R3) C++98 convertibility to bool was too weak to reflect the expectation of implementations requirements strengthened [edit] See also specifies that a type can be used in Boolean contexts
(exposition-only concept*)[edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4