The container type is a 0-size, 0-shape prototype that represents the
"container" of x
. A container is generally an S3 class that can hold
multiple different "inner" types. For example, an rray is a container
that can hold integers, logicals, or doubles as inner types.
For base R objects, this returns logical()
.
For more complex types, a method should be written that returns an
empty version of the input with no shape or size. If that complex type
can have multiple inner types, pick one to return consistently for all
inner type variations, as there should be no reliance on the inner type
when inspecting the container type.
The common container type is useful alongside vec_cast_container()
.
For example, rray_greater()
uses vec_type_container_common()
to determine the common container for the output, and then uses
vec_cast_container()
to restore the logical result of the comparison
to either an rray or an array, depending on the container type.
Critically, the container type is independent of the inner type of a
vector. This means that while vec_type_common(character(), numeric())
is an error, vec_type_container_common(character(), numeric())
returns logical()
because they are both base R containers.