Skip to content

Commit b4d7e74

Browse files
committed
[variant.visit] Rephrase specification of 'visit' to be more technically correct and precise
1 parent 487e870 commit b4d7e74

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

source/utilities.tex

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4838,32 +4838,36 @@
48384838

48394839
\begin{itemdescr}
48404840
\pnum
4841-
\requires
4842-
The expression in the \effects element shall be a valid expression of the same
4843-
type and value category, for all combinations of alternative types of all
4844-
variants. Otherwise, the program is ill-formed.
4845-
4846-
\pnum
4847-
\effects
4848-
Let \tcode{is...} be \tcode{vars.index()...}. Returns:
4841+
Let $n$ be \tcode{sizeof...(Variants)}. Let \tcode{m} be a pack of $n$
4842+
values of type \tcode{size_t}. Such a pack is called valid if $0 \leq
4843+
\tcode{m}_i < \tcode{variant_size_v<remove_reference_t<Variants}_i\tcode{>>}$ for
4844+
all $0 \leq i < n$. For each valid pack $\tcode{m}$, let $e(\tcode{m})$
4845+
denote the expression:
48494846
\begin{codeblock}
4850-
@\placeholdernc{INVOKE}@(std::forward<Visitor>(vis), get<is>(std::forward<Variants>(vars))...) // see \ref{func.require}
4847+
@\placeholder{INVOKE}@(std::forward<Visitor>(vis), get<m>(std::forward<Variants>(vars))...) // see \ref{func.require}
48514848
\end{codeblock}
48524849

48534850
\pnum
4854-
\remarks
4855-
The return type is the common type of all possible \tcode{\placeholder{INVOKE}}
4856-
expressions of the \effects element.
4851+
\requires
4852+
For each valid pack \tcode{m}, $e(\tcode{m})$ shall be a valid expression.
4853+
All such expressions shall be of the same type and value category;
4854+
otherwise, the program is ill-formed.
4855+
4856+
\pnum
4857+
\returns $e(\tcode{m})$, where \tcode{m} is the pack for which
4858+
$\tcode{m}_i$ is \tcode{vars$_i$.index()} for
4859+
all $0 \leq i < n$. The return type is the type of $e(\tcode{m})$.
48574860

48584861
\pnum
48594862
\throws
48604863
\tcode{bad_variant_access} if any \tcode{variant} in \tcode{vars} is \tcode{valueless_by_exception()}.
48614864

48624865
\pnum
48634866
\complexity
4864-
For \tcode{sizeof...(Variants) <= 1}, the invocation of the callable object is
4865-
implemented in constant time, i.e., it does not depend on \tcode{sizeof...(Types).}
4866-
For \tcode{sizeof...(Variants) > 1}, the invocation of the callable object has
4867+
For $n \leq 1$, the invocation of the callable object is
4868+
implemented in constant time, i.e., for $n = 1$, it does not depend on
4869+
the number of alternative types of $\tcode{Variants}_0$.
4870+
For $n > 1$, the invocation of the callable object has
48674871
no complexity requirements.
48684872
\end{itemdescr}
48694873

0 commit comments

Comments
 (0)