23 General utilities library [utilities]

23.7 Variants [variant]

23.7.7 Visitation [variant.visit]

template <class Visitor, class... Variants> constexpr see below visit(Visitor&& vis, Variants&&... vars);
Requires: The expression in the Effects: element shall be a valid expression of the same type and value category, for all combinations of alternative types of all variants.
Otherwise, the program is ill-formed.
Effects: Let is... be vars.index()....
Returns INVOKE(forward<Visitor>(vis), get<is>(forward<Variants>(vars))...);.
Remarks: The return type is the common type of all possible INVOKE expressions of the Effects: element.
Throws: bad_­variant_­access if any variant in vars is valueless_­by_­exception().
Complexity: For sizeof...(Variants) <= 1, the invocation of the callable object is implemented in constant time, i.e. it does not depend on sizeof...(Types). For sizeof...(Variants) > 1, the invocation of the callable object has no complexity requirements.