tmp/tmpacbfd7vj/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Boolean testability <a id="concept.booleantestable">[[concept.booleantestable]]</a>
|
| 2 |
+
|
| 3 |
+
The exposition-only `boolean-testable` concept specifies the
|
| 4 |
+
requirements on expressions that are convertible to `bool` and for which
|
| 5 |
+
the logical operators ([[expr.log.and]], [[expr.log.or]],
|
| 6 |
+
[[expr.unary.op]]) have the conventional semantics.
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
template<class T>
|
| 10 |
+
concept boolean-testable-impl = convertible_to<T, bool>; // exposition only
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
Let `e` be an expression such that `decltype((e))` is `T`. `T` models
|
| 14 |
+
`boolean-testable-impl` only if:
|
| 15 |
+
|
| 16 |
+
- either `remove_cvref_t<T>` is not a class type, or name lookup for the
|
| 17 |
+
names `operator&&` and `operator||` within the scope of
|
| 18 |
+
`remove_cvref_t<T>` as if by class member access lookup
|
| 19 |
+
[[class.member.lookup]] results in an empty declaration set; and
|
| 20 |
+
- name lookup for the names `operator&&` and `operator||` in the
|
| 21 |
+
associated namespaces and entities of `T` [[basic.lookup.argdep]]
|
| 22 |
+
finds no disqualifying declaration (defined below).
|
| 23 |
+
|
| 24 |
+
A *disqualifying parameter* is a function parameter whose declared type
|
| 25 |
+
`P`
|
| 26 |
+
|
| 27 |
+
- is not dependent on a template parameter, and there exists an implicit
|
| 28 |
+
conversion sequence [[over.best.ics]] from `e` to `P`; or
|
| 29 |
+
- is dependent on one or more template parameters, and either
|
| 30 |
+
- `P` contains no template parameter that participates in template
|
| 31 |
+
argument deduction [[temp.deduct.type]], or
|
| 32 |
+
- template argument deduction using the rules for deducing template
|
| 33 |
+
arguments in a function call [[temp.deduct.call]] and `e` as the
|
| 34 |
+
argument succeeds.
|
| 35 |
+
|
| 36 |
+
A *key parameter* of a function template `D` is a function parameter of
|
| 37 |
+
type cv `X` or reference thereto, where `X` names a specialization of a
|
| 38 |
+
class template that is a member of the same namespace as `D`, and `X`
|
| 39 |
+
contains at least one template parameter that participates in template
|
| 40 |
+
argument deduction.
|
| 41 |
+
|
| 42 |
+
[*Example 1*:
|
| 43 |
+
|
| 44 |
+
In
|
| 45 |
+
|
| 46 |
+
``` cpp
|
| 47 |
+
namespace Z {
|
| 48 |
+
template<class> struct C {};
|
| 49 |
+
template<class T>
|
| 50 |
+
void operator&&(C<T> x, T y);
|
| 51 |
+
template<class T>
|
| 52 |
+
void operator||(C<type_identity_t<T>> x, T y);
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
the declaration of `Z::operator&&` contains one key parameter, `C<T> x`,
|
| 57 |
+
and the declaration of `Z::operator||` contains no key parameters.
|
| 58 |
+
|
| 59 |
+
— *end example*]
|
| 60 |
+
|
| 61 |
+
A *disqualifying declaration* is
|
| 62 |
+
|
| 63 |
+
- a (non-template) function declaration that contains at least one
|
| 64 |
+
disqualifying parameter; or
|
| 65 |
+
- a function template declaration that contains at least one
|
| 66 |
+
disqualifying parameter, where
|
| 67 |
+
- at least one disqualifying parameter is a key parameter; or
|
| 68 |
+
- the declaration contains no key parameters; or
|
| 69 |
+
- the declaration declares a function template that is not visible in
|
| 70 |
+
its namespace [[namespace.memdef]].
|
| 71 |
+
|
| 72 |
+
[*Note 1*: The intention is to ensure that given two types `T1` and
|
| 73 |
+
`T2` that each model `boolean-testable-impl`, the `&&` and `||`
|
| 74 |
+
operators within the expressions `declval<T1>() && declval<T2>()` and
|
| 75 |
+
`declval<T1>() || declval<T2>()` resolve to the corresponding built-in
|
| 76 |
+
operators. — *end note*]
|
| 77 |
+
|
| 78 |
+
``` cpp
|
| 79 |
+
template<class T>
|
| 80 |
+
concept boolean-testable = // exposition only
|
| 81 |
+
boolean-testable-impl<T> && requires (T&& t) {
|
| 82 |
+
{ !std::forward<T>(t) } -> boolean-testable-impl;
|
| 83 |
+
};
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
Let `e` be an expression such that `decltype((e))` is `T`. `T` models
|
| 87 |
+
`boolean-testable` only if `bool(e) == !bool(!e)`.
|
| 88 |
+
|
| 89 |
+
[*Example 2*: The types `bool`, `true_type` [[meta.type.synop]],
|
| 90 |
+
`int*`, and `bitset<N>::reference` [[template.bitset]] model
|
| 91 |
+
*`boolean-testable`*. — *end example*]
|
| 92 |
+
|