From aebcb9792d5d4ec5b104a42e02b27fd6b053b160 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 15 Sep 2021 02:00:33 +0300 Subject: [PATCH] Update documentation of visit_by_index --- doc/variant2/reference.adoc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/variant2/reference.adoc b/doc/variant2/reference.adoc index 5748989..897fbf4 100644 --- a/doc/variant2/reference.adoc +++ b/doc/variant2/reference.adoc @@ -151,8 +151,8 @@ template // visit_by_index (extension) -template - void visit_by_index(V&& v, F&&.. f); +template + constexpr /*see below*/ visit_by_index(V&& v, F&&.. f); // monostate @@ -899,16 +899,20 @@ Remarks: :: If `R` is given explicitly, as in `visit`, the return ### visit_by_index (extension) ``` -template - void visit_by_index(V&& v, F&&.. f); +template + constexpr /*see below*/ visit_by_index(V&& v, F&&.. f); ``` [none] * {blank} + Requires: :: `variant_size::value == sizeof...(F)`, or the program is ill-formed. -Effects: :: `std::forward(fi)(get(std::forward(v)))`, where +Returns: :: `std::forward(fi)(get(std::forward(v)))`, where `i` is `v.index()` and `Fi` and `fi` are the `i`-th element of `F...` and `f...` accordingly. +Remarks: :: If `R` is given explicitly, as in `visit_by_index`, the return + type is `R`. Otherwise, it's deduced from `F...` and `V`. All the applications + of `Fi` to the corresponding variant alternatives must have the same return type + for this deduction to succeed. ### swap