cpp/utility/variant/visit

Applies the visitor (a  that can be called with any combination of types from variants) to the variants.

Given as  (a pack of  types): @1@ Invokes as if by, where  is. @2@ Invokes as if by, where  is.

If the expression denoted by is invalid, or the results of  have different types or value categories for different, the program is ill-formed.

@3-6@ The exposition-only function templates accept a value whose type can be deduced for  (i.e. either  or a type derived from ), and return the std value with the same const-qualification and value category.
 * @3,4@ Returns.
 * @5,6@ Returns.

Return value
@1@ The result of the operation. The return type is the type obtained from applying to the result. @2@ Nothing if is (possibly cv-qualified) ; otherwise the result of the  operation. @3-6@ A std value converted from.

Exceptions
Throws std if is  for any variant  in.

Complexity
When the number of variants is zero or one, the invocation of the callable object is implemented in constant time, i.e. it does not depend on the number of types can be stored in the variant.

If the number of variants is larger than one, the invocation of the callable object has no complexity requirements.