Denote an index-distinguishing operation to be performed in-place. An instance of this type can be passed to certain constructors of ara::core::Variant to denote the intention that construction of the contained type shall be done in-place, i.e. without any copying taking place.
Serves as a tag type for direct in-place construction of a value in a variant based on its index.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 39c809af4202ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as a tag type for direct in-place construction of a value in a variant based on its index.
The class template ara::core::in_place_index_t serves as a tag type to designate in-place constructions at a specific index within ara::core::Variant in order to avoid unnecessary copy or move operations of the target value. Instances are selectively passed to suitable variant constructors, with creation taking place via the default constructor from ara/core/utility.h[SWS_CORE_04032]. Since the constructor is defined as explicit and noexcept, implicit type conversions are excluded and instantiation is guaranteed to be exception-safe [SWS_CORE_04032].
Context
The class template ara::core::in_place_index_t is a helper structure in module core of the AUTOSAR Adaptive Platform and is made available via header file ara/core/utility.h[SWS_CORE_04032]. Its functional role is to serve as a unique tag type for in-place operations that are distinguished via a numeric index. An instance of this type is passed to specific constructors of ara::core::Variant to indicate the intention that construction of the contained type is to take place directly in-place without performing copy or move operations.
In the collaboration between caller and the sum type ara::core::Variant, ara::core::in_place_index_t assumes the function of tag dispatching. Interpretation: The index-based distinction is likely relevant in particular for variant instances that contain multiple alternatives of the same type; in this case, selection via data type alone would be ambiguous, so addressing via template parameter Index determines the exact type alternative in the type pack. Question Q-fc429a7c9e7e9362 (open)
Lifecycle
The lifecycle of ara::core::in_place_index_t is elementary and free of complex state transitions. Creation takes place via the default constructor explicit in_place_index_t() noexcept = default;[SWS_CORE_04032]. Marking it as explicit prevents implicit type conversion, which enforces explicit and strictly typed instantiation [SWS_CORE_04032].
Since ara::core::in_place_index_t acts as a pure indicator and possesses no internal attributes or dynamic resources, the object is completely stateless. Destruction is trivial and entails no side effects. With respect to concurrency, the structure is inherently thread-safe: Since no mutable states exist, instances can be used across thread boundaries without synchronization overhead.
Usage Path
The typical sequence for using ara::core::in_place_index_t is divided into the following steps:
Index determination: The caller determines the numeric template parameter Index, which represents the desired alternative within the ara::core::Variant.
Tag instantiation: An instance of ara::core::in_place_index_t<Index> is created via the default constructor [SWS_CORE_04032]. Interpretation: In practice, creation is expected to take place preferably as a temporary argument directly in the call. Question Q-7c6292c2e97347b0 (open)
Constructor passing: The tag instance is passed as the first argument to the constructor of ara::core::Variant, followed by the constructor arguments for the target type managed at this position.
Direct initialization:ara::core::Variant constructs the target object directly in the provided memory area without prior creation of temporary copies.
Sequence diagram: Typical sequence of in-place construction of a variant value via ara::core::in_place_index_t. Sources: [SWS_CORE_04032]
Error Scenarios
Regarding fault tolerance, ara::core::in_place_index_t is characterized by maximum robustness. The default constructor is specified with noexcept and is considered exception safe ("exception safe") [SWS_CORE_04032]. There are neither error codes nor defined error states for this structure.
Erroneous usages with implicit conversions are rejected at compile time by the specification as explicit[SWS_CORE_04032]. If an exception is thrown during the execution of the in-place constructor of ara::core::Variant, it does not originate from ara::core::in_place_index_t, but is rooted in the error behavior of the constructed target type.
This guide was generated by an AI based on the AUTOSAR specification R25-11.
UML class diagram
Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.
gemini-3.8-flash-low· 2026-10-13 · German original