absl::AnySpan::AnySpan

Constructs a span wrapping a const view container (transform by copy).

Synopsis

Declared in <absl/types/any_span.h>

template<
    typename Container,
    typename Transform,
    typename = EnableIfContainer<Container>,
    typename = EnableIfTransformIsValid<Transform, decltype(std::declval<const Container&>()[0])>,
    EnableIfTransformIsByCopy<Transform> = true>
constexpr
AnySpan(
    Container const& container,
    Transform const& transform);

Description

Enabled even for mutable spans, since some views expose mutable element access when const. The transform, container, and its storage must outlive this span; reallocating or resizing the container invalidates the span.

Parameters

NameDescription
containerThe container whose elements the span refers to.
transformFunctor applied to each element on access.