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

Detailed Description

Outline

Purpose

Provide the most awkward type that is convertible to bool.

Classes

See also
bsltf_templatetestfacility

Description

This component provides a type that is convertible-to-bool, and so may be used to satisfy many C++ standard library requirements, but is perversely implemented to provide the most awkward interface that meets the requirements. This type is not intended for use in production code, but is most useful when implementing test drivers for generic components that must accept predicates, or other expressions, that yield a type that is merely convertible to bool.

Usage

This section illustrates intended use of this component.

Example 1: Basic Syntax

The following snippets of code provide a simple illustration of using bsltf::EvilBooleanType.

First, we create an object trueValue and initialize it with the true value:

bsltf::EvilBooleanType trueValue(true);
Definition bsltf_evilbooleantype.h:111

Now, we can use it for if-else conditions or another constructions, that require boolen value:

if (trueValue) {
assert(trueValue);
}

Finally we create another object, having the opposite value, and verify it:

bsltf::EvilBooleanType falseValue = !trueValue;
assert(false == (bool)falseValue);