forked from boostorg/variant2
Document visit_by_index
This commit is contained in:
@ -12,6 +12,7 @@ https://www.boost.org/LICENSE_1_0.txt
|
|||||||
|
|
||||||
* Added `<boost/variant2.hpp>`.
|
* Added `<boost/variant2.hpp>`.
|
||||||
* Added `unsafe_get<I>`.
|
* Added `unsafe_get<I>`.
|
||||||
|
* Added `visit_by_index`.
|
||||||
|
|
||||||
## Changes in 1.76.0
|
## Changes in 1.76.0
|
||||||
|
|
||||||
|
@ -169,6 +169,10 @@ The main differences between this implementation and `std::variant` are:
|
|||||||
`variant<int, float>` is provided as the member function `subset<U...>`.
|
`variant<int, float>` is provided as the member function `subset<U...>`.
|
||||||
(This operation can throw if the current state of the variant cannot be
|
(This operation can throw if the current state of the variant cannot be
|
||||||
represented.)
|
represented.)
|
||||||
|
* `unsafe_get`, an unchecked alternative to `get` and `get_if`, is provided
|
||||||
|
as an extension.
|
||||||
|
* `visit_by_index`, a visitation function that takes a single variant and a
|
||||||
|
number of function objects, one per alternative, is provided as an extension.
|
||||||
* The {cpp}20 additions and changes to `std::variant` have not yet been
|
* The {cpp}20 additions and changes to `std::variant` have not yet been
|
||||||
implemented.
|
implemented.
|
||||||
|
|
||||||
|
@ -149,6 +149,11 @@ template<class... T>
|
|||||||
template<class R = /*unspecified*/, class F, class... V>
|
template<class R = /*unspecified*/, class F, class... V>
|
||||||
constexpr /*see below*/ visit(F&& f, V&&... v);
|
constexpr /*see below*/ visit(F&& f, V&&... v);
|
||||||
|
|
||||||
|
// visit_by_index (extension)
|
||||||
|
|
||||||
|
template<class V, class... F>
|
||||||
|
void visit_by_index(V&& v, F&&.. f);
|
||||||
|
|
||||||
// monostate
|
// monostate
|
||||||
|
|
||||||
struct monostate {};
|
struct monostate {};
|
||||||
@ -891,6 +896,20 @@ Remarks: :: If `R` is given explicitly, as in `visit<int>`, the return
|
|||||||
of `F` to the variant alternatives must have the same return type for
|
of `F` to the variant alternatives must have the same return type for
|
||||||
this deduction to succeed.
|
this deduction to succeed.
|
||||||
|
|
||||||
|
### visit_by_index (extension)
|
||||||
|
|
||||||
|
```
|
||||||
|
template<class V, class... F>
|
||||||
|
void visit_by_index(V&& v, F&&.. f);
|
||||||
|
```
|
||||||
|
[none]
|
||||||
|
* {blank}
|
||||||
|
+
|
||||||
|
Requires: :: `variant_size<V>::value == sizeof...(F)`, or the program is ill-formed.
|
||||||
|
Effects: :: `std::forward<Fi>(fi)(get<i>(std::forward<V>(v)))`, where
|
||||||
|
`i` is `v.index()` and `Fi` and `fi` are the `i`-th element of `F...` and `f...`
|
||||||
|
accordingly.
|
||||||
|
|
||||||
### swap
|
### swap
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user