tmp/tmp59rrrruo/{from.md → to.md}
RENAMED
|
@@ -1,26 +1,41 @@
|
|
| 1 |
### Visitation <a id="variant.visit">[[variant.visit]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class Visitor, class... Variants>
|
| 5 |
constexpr see below visit(Visitor&& vis, Variants&&... vars);
|
|
|
|
|
|
|
| 6 |
```
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
*
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
*Throws:* `bad_variant_access` if any `variant` in `vars` is
|
| 20 |
`valueless_by_exception()`.
|
| 21 |
|
| 22 |
-
*Complexity:* For
|
| 23 |
-
|
| 24 |
-
|
| 25 |
the callable object has no complexity requirements.
|
| 26 |
|
|
|
|
| 1 |
### Visitation <a id="variant.visit">[[variant.visit]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class Visitor, class... Variants>
|
| 5 |
constexpr see below visit(Visitor&& vis, Variants&&... vars);
|
| 6 |
+
template<class R, class Visitor, class... Variants>
|
| 7 |
+
constexpr R visit(Visitor&& vis, Variants&&... vars);
|
| 8 |
```
|
| 9 |
|
| 10 |
+
Let n be `sizeof...(Variants)`. Let `m` be a pack of n values of type
|
| 11 |
+
`size_t`. Such a pack is called valid if 0 ≤
|
| 12 |
+
`mᵢ` < `variant_size_v<remove_reference_t<Variantsᵢ``>>` for all
|
| 13 |
+
0 ≤ i < n. For each valid pack `m`, let e(`m`) denote the expression:
|
| 14 |
|
| 15 |
+
``` cpp
|
| 16 |
+
INVOKE(std::forward<Visitor>(vis), get<m>(std::forward<Variants>(vars))...) // see [func.require]
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
for the first form and
|
| 20 |
+
|
| 21 |
+
``` cpp
|
| 22 |
+
INVOKE<R>(std::forward<Visitor>(vis), get<m>(std::forward<Variants>(vars))...) // see [func.require]
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
for the second form.
|
| 26 |
+
|
| 27 |
+
*Mandates:* For each valid pack `m`, e(`m`) is a valid expression. All
|
| 28 |
+
such expressions are of the same type and value category.
|
| 29 |
|
| 30 |
+
*Returns:* e(`m`), where `m` is the pack for which `mᵢ` is
|
| 31 |
+
`vars`ᵢ`.index()` for all 0 ≤ i < n. The return type is
|
| 32 |
+
`decltype(`e(`m`)`)` for the first form.
|
| 33 |
|
| 34 |
*Throws:* `bad_variant_access` if any `variant` in `vars` is
|
| 35 |
`valueless_by_exception()`.
|
| 36 |
|
| 37 |
+
*Complexity:* For n ≤ 1, the invocation of the callable object is
|
| 38 |
+
implemented in constant time, i.e., for n = 1, it does not depend on the
|
| 39 |
+
number of alternative types of `Variants₀`. For n > 1, the invocation of
|
| 40 |
the callable object has no complexity requirements.
|
| 41 |
|