This function should typically be called from the default vec_cast() method for your class, e.g. vec_cast.myclass.default(). It does two things:

• If x is an unspecified vector, it automatically casts it to to using vec_init().

• Otherwise, an error is thrown with stop_incompatible_cast().

vec_default_cast(x, to, x_arg = "x", to_arg = "to")

## Arguments

x Vectors to cast. Type to cast to. If NULL, x will be returned as is. Argument names for x and to. These are used in error messages to inform the user about the locations of incompatible types (see stop_incompatible_type()). Argument names for x and to. These are used in error messages to inform the user about the locations of incompatible types (see stop_incompatible_type()).