From Jason Turner

[variant.visit]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp59rrrruo/{from.md → to.md} +26 -11
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
- *Requires:* The expression in the *Effects:* element shall be a valid
9
- expression of the same type and value category, for all combinations of
10
- alternative types of all variants. Otherwise, the program is ill-formed.
 
11
 
12
- *Effects:* Let `is...` be `vars.index()...`. Returns
13
- *INVOKE*(forward\<Visitor\>(vis), get\<is\>(
14
- `forward<Variants>(vars))...);`.
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- *Remarks:* The return type is the common type of all possible *`INVOKE`*
17
- expressions of the *Effects:* element.
 
18
 
19
  *Throws:* `bad_variant_access` if any `variant` in `vars` is
20
  `valueless_by_exception()`.
21
 
22
- *Complexity:* For `sizeof...(Variants) <= 1`, the invocation of the
23
- callable object is implemented in constant time, i.e. it does not depend
24
- on `sizeof...(Types).` For `sizeof...(Variants) > 1`, the invocation of
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