Provide the most awkward type that is convertible to bool
.
More...
Namespaces |
namespace | bsltf |
Detailed Description
- Outline
-
-
- Purpose:
- Provide the most awkward type that is convertible to
bool
.
-
- Classes:
-
- See also:
- Component 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: 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: