Provides an efficient, non-owning view of contiguous memory areas of arbitrary containers or buffers.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: cd35d03068cbProvenanceOpen questions (3)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Provides an efficient, non-owning view of contiguous memory areas of arbitrary containers or buffers.
The class ara::core::Span provides a non-owning, contiguous view of memory areas and allows efficient encapsulation of arrays or buffers without copy overhead [SWS_CORE_01942]. Applications typically use the class for passing data windows and for creating subviews by means of slicing operations. Callers must strictly ensure that the lifetime of the underlying memory outlasts that of the view and that valid bounds are observed during operations such as subspan(), since out-of-bounds violations trigger undefined behavior [SWS_CORE_01966].
Context
The class ara::core::Span represents a standard-compliant implementation of a contiguous sequence view based on std::span from [views.span]. As a lightweight abstraction, it encapsulates a pointer to the first element and the number of available elements without owning the data itself. It serves as a uniform interface between components that provide data and algorithms that process this data.
The primary interaction partners include:
Calling application logic: Uses the view for read or write accesses to sequential memory areas without memory allocations or copy overhead.
Instances of ara::core::Span are designed as pure value objects without their own resource management. Creation is performed either as an empty span via the default constructor [SWS_CORE_01941], by directly specifying start address and element count [SWS_CORE_01942], or via a pointer range consisting of begin and end [SWS_CORE_01943]. In addition, typed constructors for C arrays [SWS_CORE_01944], containers of type ara::core::Array[SWS_CORE_01945][SWS_CORE_01946], and generic containers [SWS_CORE_01947][SWS_CORE_01948] are available. Existing spans can be duplicated via the default copy constructor [SWS_CORE_01949] or via converting constructors with compatible element types and extents [SWS_CORE_01950].
Since ara::core::Span assumes no ownership whatsoever of the referenced data, the destructor has the default implementation and is specified as noexcept=default[SWS_CORE_01951]. This leads to the fundamental invariant (Interpretation: Assumption 1) that the lifetime of the underlying memory buffer must always at least span the lifetime of all span objects referencing it; if the buffer is destroyed, remaining spans become invalid. Question (open) Assignment via the assignment operator occurs trivially via shallow copy [SWS_CORE_01952]. Since all access functions are declared as noexcept and have no internal synchronization mechanisms, concurrent read access to the same span instance from multiple threads is likely safe provided that the underlying memory area is not modified concurrently (Interpretation: Assumption 2). Question Q-be5a38c1097c4ee1 (open)
Usage Path
A typical use case comprises encapsulating an existing data block, checking dimensions, extracting relevant sections, and accessing the elements:
View creation: The application instantiates ara::core::Span on a contiguous buffer, for instance from an instance of ara::core::Array[SWS_CORE_01945] or via raw data pointers with length specification [SWS_CORE_01942].
All methods of ara::core::Span are declared as exception-safe and noexcept; neither are C++ exceptions thrown nor error objects such as ara::core::ErrorCode returned. Error states result primarily from violations of preconditions, which lead directly to undefined behavior (Undefined Behavior):
Size exceeded for prefixes and suffixes: If a count is requested in first() that exceeds the current size (Count > size() or count > size(), respectively), the behavior is undefined [SWS_CORE_01961][SWS_CORE_01962]. The identical precondition violation also leads to undefined behavior in last()[SWS_CORE_01963][SWS_CORE_01964].
Invalid sub-range parameters in subspan: Calling subspan() mandatorily requires that offset <= size() holds and, with explicitly specified count (not equal to dynamic_extent), that count <= size() - offset is also observed. Non-compliance leads to undefined behavior [SWS_CORE_01966].
Out of bounds on element access: The subscript operator operator[][SWS_CORE_01970] as well as the access functions front()[SWS_CORE_01959] and back()[SWS_CORE_01960] perform no bounds checking. Access outside valid bounds is likely to lead directly to undefined memory accesses (Interpretation: Assumption 3). Question (open)
This guide is based on the AUTOSAR Adaptive R25-11 specification and was generated automatically.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 557e5938932aProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function crbegin of class ara::core::Span returns a constant reverse iterator pointing to the last element of the referenced sequence [SWS_CORE_01978]. The function requires header file #include "ara/core/span.h" and follows the usage in [views.span][SWS_CORE_01978]. The return value of type const_reverse_iterator allows read-only reverse iteration over the memory range described by the span [SWS_CORE_01978].
Since crbegin is declared as constexpr, evaluation can already take place at compile time [SWS_CORE_01978]. Regarding error handling, the function is declared as noexcept and classified as exception safe; consequently, it throws no exceptions, and neither error codes nor DET or DEM messages exist [SWS_CORE_01978].
Regarding concurrency and restrictions, the method is const-qualified; interpretation: parallel read calls on the same instance should be thread-safe without external synchronization as long as the underlying memory range is not modified at the same time [SWS_CORE_01978]. Question Q-d63c0354556f1d23 (open)
In interaction with other elements of ara::core, crbegin follows a uniform pattern for containers and views:
ara::core::Array provides a corresponding constexpr and exception safe interface [SWS_CORE_01260].
ara::core::StringView likewise provides crbegin as constexpr and exception safe[SWS_CORE_02126].
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 464fedb451c3ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function crend of template class ara::core::Span ([SWS_CORE_01979]) synchronously returns a constant reverse iterator of type const_reverse_iterator. The function requires inclusion of header file ara/core/span.h and takes no invocation parameters. According to the specification, the behavior follows standard usage in [views.span]. Interpretation: The returned iterator should represent the theoretical position immediately preceding the first element of the range and thus serve as a termination condition during reverse iteration. Question Q-83d4ed4a6e68fb19 (open)
Error Handling and Concurrency
The function is declared as noexcept and explicitly classified as exception safe ([SWS_CORE_01979]). A call triggers no exceptions, and neither error return values nor specific error logging via DET or DEM exist. Since crend is defined as constexpr, evaluation can take place directly at compile time. As a pure const member function, it does not alter the state of the instance; concurrent read accesses to the same Span instance should therefore be thread-safe without synchronization. Question Q-d90bd6b4f01c8af6 (open)
Interaction
The behavior of crend in ara::core::Span fits seamlessly into the sequence and container interfaces of ara::core:
ara::core::Array ([SWS_CORE_01261]) and ara::core::StringView ([SWS_CORE_02127]) offer identical signatures, also declared as constexpr and noexcept.
ara::core::Vector ([SWS_CORE_01343]), ara::core::Map ([SWS_CORE_01451]), and ara::core::BasicString ([SWS_CORE_03050]) provide analogous const_reverse_iterator endpoints for dynamic containers.
This usage note was generated by an AI based on the AUTOSAR R25-11 specification.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: daa0dd011e1eProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template member function first<Count>() of class ara::core::Span synchronously creates a new subspan over the first Count elements of the current span and returns it as ara::core::Span<element_type, Count>[SWS_CORE_01961]. The function is declared in header file ara/core/span.h and specified as constexpr as well as const noexcept[SWS_CORE_01961].
Regarding error handling, the function is classified as exception safe (exception safe) and throws no exceptions [SWS_CORE_01961]. Specific error codes, error return values, or notifications to DET or DEM are not defined. However, a mandatory precondition exists: Behavior is undefined if template parameter Count is greater than the runtime size of the span (Count > size()) [SWS_CORE_01961]. Callers must therefore ensure that sufficient elements are present.
Since the method is declared as const and does not modify the underlying Span object, concurrent read access across multiple threads is expected to be thread-safe without additional locks (interpretation). Question Q-215ae1cc00b7a590 (open) If the addressed elements of the span are modified by other threads in the meantime, access must be synchronized externally.
This text was created by an AI. All technical details are based exclusively on the specification of AUTOSAR R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 2bb3b51c18a9ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function first is called on an instance of ara::core::Span (provided via header ara/core/span.h) to create a subview of the first elements of a sequence [SWS_CORE_01962]. The requested number of elements count of type size_type is passed as a parameter [SWS_CORE_01962]. The return value is a Span<element_type, dynamic_extent>, which represents the corresponding prefix [SWS_CORE_01962]. The behavior follows the semantics of [views.span] from the C++ standard [SWS_CORE_01962]. Through the declaration as constexpr and noexcept, the method operates synchronously, exception-free, and can already be evaluated at compile time [SWS_CORE_01962].
Error Handling and Boundary Conditions
The function is specified as exception safe (exception safe); error codes or specific error messages (such as DET or DEM) are not provided [SWS_CORE_01962]. For the caller, the following binding constraint applies:
The behavior of the function is undefined (undefined behavior) if count > size() is [SWS_CORE_01962].
The using program code must therefore verify independently prior to the call that the requested number of elements does not exceed the actual size of the span.
Concurrency and Limitations
As a const member function (const), first does not modify the called span [SWS_CORE_01962]. The specification remains silent regarding thread safety; concurrent read accesses to the same span and the underlying sequence data should, however, be uncritical (interpretation). Question Q-8c3b51e54157dc12 (open) If the referenced elements are modified concurrently by other threads, external synchronization is required.
This text was generated by an AI based on the AUTOSAR specification R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 762c5c7c0428ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template member function [SWS_CORE_01963] of class ara::core::Span (header #include "ara/core/span.h") synchronously returns a subview of the last Count elements of the underlying sequence. It follows the semantics of [views.span][SWS_CORE_01963]. Since the parameter Count is passed as a template argument, the resulting Span object has a static extent that is already fixed at compile time.
The operation is declared as constexpr, const, as well as noexcept, and specified as exception-safe (exception safe) [SWS_CORE_01963]. Error returns via error codes or notifications to DET or DEM are not provided for this function. However, undefined behavior occurs if Count > size() is [SWS_CORE_01963]. Callers must therefore ensure before instantiation or execution that the current span comprises at least the required number of elements.
Regarding concurrency, the specification makes no explicit statement on thread safety; however, as a side-effect-free const method, concurrent read access by multiple threads to the same Span instance should be uncritical, provided that the referenced elements in memory are not modified concurrently. Question Q-120ccf3995c86b47 (open)
In interaction within the module, the function complements overload [SWS_CORE_01964]: While the present variant [SWS_CORE_01963] requires a fixed extent at compile time, [SWS_CORE_01964] allows specifying a variable number of elements at runtime and returns a Span with dynamic extent (dynamic_extent).
This text was generated by an AI system based on the specification data of AUTOSAR R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: f839f8230576ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function last of class ara::core::Span creates a subview (subspan) that comprises the last count elements of the current sequence [SWS_CORE_01964]. The call occurs synchronously and returns a Span<element_type, dynamic_extent>[SWS_CORE_01964]. Because the function is declared as constexpr and noexcept, it can also be evaluated at compile time and guarantees complete exception safety (exception safe) [SWS_CORE_01964].
Error Handling and Boundary Conditions
The function does not throw exceptions. An erroneous call occurs when the argument count exceeds the actual number of present elements (count > size()); in this case, the behavior is undefined [SWS_CORE_01964]. Callers must therefore ensure before passing dynamic values that the requested number of elements lies within the valid range.
Concurrency and Interaction
Because last represents a stateless read operation on the span instance, concurrent calls via the same Span are likely uncritical as long as the underlying sequence elements are not modified. Question Q-ec2beaa99d9627c0 (open) In contrast to the template variant last<Count>()[SWS_CORE_01963], which statically determines the size, this overload determines the length at runtime. Newly created sequences, for instance via MakeSpan[SWS_CORE_01991], can thus be flexibly reduced to their suffix.
This usage note was created automatically. All information is based on the specification of AUTOSAR Adaptive Core R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 3b4cbcd12a0eProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function size_bytes of class ara::core::Span returns the total size of the referenced memory area in bytes [SWS_CORE_01968]. The semantics correspond to the definition in standard C++ according to [views.span][SWS_CORE_01968].
use
The function is called synchronously on an existing instance of ara::core::Span and requires the inclusion of header ara/core/span.h[SWS_CORE_01968]:
Call context and parameters: The method is parameterless and declared as const, thus does not change the state of the span [SWS_CORE_01968]. Due to the designation as constexpr, the value can already be evaluated at compile time, provided that the underlying context permits this [SWS_CORE_01968].
Return value: Returns a value of type size_type, which represents the byte size of the represented memory [SWS_CORE_01968].
Error Handling and Exception Safety
The function is declared as noexcept and specifies the guarantee level exception safe[SWS_CORE_01968]. No C++ exceptions occur and no error codes are returned [SWS_CORE_01968].
Concurrency and Limitations
Since size_bytes is a pure read operation (const) without side effects, concurrent calling on the same instance from multiple threads is non-critical, provided that the referenced Span object is not modified simultaneously (interpretation: standard thread safety for const methods) [SWS_CORE_01968]. Question Q-ea768d4f6fa1d12f (open)
This usage note was generated automatically based on the AUTOSAR specification R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: dca812068dbfProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function subspan of class ara::core::Span creates a subview of an existing span ([SWS_CORE_01965]). Via the template parameters Offset and Count, the starting position and the number of elements are statically defined at compile time; by default, Count is set to dynamic_extent. The call is synchronous, declared as constexpr and noexcept, and considered exception-safe ([SWS_CORE_01965]).
Regarding the behavior, the specification refers to the C++ standard construct [views.span] ([SWS_CORE_01965]). Unlike the overloaded runtime function [SWS_CORE_01966], where invalid bounds explicitly lead to undefined behavior, checking here primarily takes place during compilation. Interpretation: With a statically known number of elements, exceeding the bounds of Offset or Count would presumably result in a compilation error. Question Q-c1b2dd93177fb266 (open)
The function is available via header #include "ara/core/span.h" ([SWS_CORE_01965]). It complements the complementary overload [SWS_CORE_01966] for cases where subranges are already fixed at compile time. Since subspan is a const member function, concurrent read accesses to the same source object are uncritical, provided the referenced memory element is not modified concurrently.
This usage note was generated automatically based on the AUTOSAR Adaptive R25-11 specification.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: a68a8b4ea86aProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function subspan of ara::core::Span ([SWS_CORE_01966]) creates a subview (subspan) on the underlying data. It is included via header ara/core/span.h. As parameters, it accepts an offset (offset) and optionally the number of elements (count), which defaults to dynamic_extent. When count == dynamic_extent is passed, the created subview presumably comprises all remaining elements starting from the specified offset. The function is declared as constexpr and noexcept and is considered exception safe (exception safe) according to the specification. Question Q-f300852e8a1a87c8 (open)
Error Handling and Boundary Conditions
The function signals errors neither via error codes nor via C++ exceptions. Instead, violation of the defined preconditions leads directly to undefined behavior ([SWS_CORE_01966]). A call is defined only if the following condition is met:
Callers must verify these range bounds independently prior to the call in order to rule out undefined behavior at runtime.
Interaction
In contrast to the template variant [SWS_CORE_01965], which binds offset and number of elements already at compile time via template parameters, [SWS_CORE_01966] allows the dynamic passing of runtime values. As return type, it always provides an instance of Span<element_type, dynamic_extent>.
This text was generated by an AI and serves as guidance based on the AUTOSAR specification.
gemini-3.8-flash-low· 2026-10-13 · German original