结构体 ara::core::in_place_index_t
[SWS_CORE_04031] Upstream: RS_AP_00130
template <std::size_t Index> struct in_place_index_t {...};
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.
Header-Datei #include "ara/core/utility.h" Forwarding-Header #include "ara/core/core_fwd.h" Scope namespace ara::core
用户指南人工智能生成 用作根据索引在 Variant 中直接就地构造值的标签类型。
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 39c809af4202
来源
未决问题(2)
摘要 详细
用作根据索引在 Variant 中直接就地构造值的标签类型。
类模板 ara::core::in_place_index_t 用作标记 ara::core::Variant 内特定索引处就地构造的标签类型,以避免目标值不必要的复制或移动操作。实例被针对性地传递给匹配的 Variant 构造函数,其中创建是通过来自 ara/core/utility.h 的默认构造函数进行的 [SWS_CORE_04032] 。由于构造函数被定义为 explicit 和 noexcept,因此排除了隐式类型转换,且实例化保证是异常安全的 [SWS_CORE_04032] 。
更多 ›
上下文
类模板 ara::core::in_place_index_t 是 AUTOSAR Adaptive Platform 模块 core 中的辅助结构体,并通过头文件 ara/core/utility.h 提供 [SWS_CORE_04032] 。其功能作用是充当通过数值索引进行区分的就地操作的唯一标签类型。该类型的一个实例被传递给 ara::core::Variant 的特定构造函数,以指示包含类型的构造应直接就地(“in-place”)执行,而不执行复制或移动操作的意图。
在调用者与和类型(sum type)ara::core::Variant 之间的协作中,ara::core::in_place_index_t 承担标签分发(tag dispatching)的功能。解读:基于索引的区分可能特别适用于包含相同类型的多个备选项的 Variant 实例;在这种情况下,仅通过数据类型进行选择会产生歧义,因此通过模板参数 Index 进行寻址决定了类型包中的精确类型备选项。 问题 Q-fc429a7c9e7e9362 (未决)
生命周期
ara::core::in_place_index_t 的生命周期非常基础,且不存在复杂的状态转换。创建通过默认构造函数 explicit in_place_index_t() noexcept = default; [SWS_CORE_04032] 进行。通过标记为 explicit 阻止了隐式类型转换,从而强制进行显式且类型严格的实例化 [SWS_CORE_04032] 。
由于 ara::core::in_place_index_t 纯粹充当指示器且不包含内部属性或动态资源,因此该对象完全是无状态的。其销毁是平凡的,不会带来任何副作用。在并发性方面,该结构体具有内在的线程安全性:由于不存在可变状态,实例可以跨线程边界使用而无需同步开销。
使用路径
使用 ara::core::in_place_index_t 的典型流程分为以下步骤:
索引确定: 调用者确定表示 ara::core::Variant 内所需备选项的数值模板参数 Index。
标签实例化: 通过默认构造函数创建 ara::core::in_place_index_t<Index> 的实例 [SWS_CORE_04032] 。解读:在实践中,创建可能优选作为临时参数直接在调用中进行。 问题 Q-7c6292c2e97347b0 (未决)
构造函数传递: 将标签实例作为第一个参数传递给 ara::core::Variant 的构造函数,后跟针对在该位置管理的目标类型的构造函数参数。
直接初始化: ara::core::Variant 直接在提供的存储区中构造目标对象,无需事先创建临时副本。
通过 in_place_index_t 原位构造 Variant 值 Anwender in_place_index_t<Index> Variant Zielobjekt explicit in_place_index_t() Tag-Instanz Variant(in_place_index_t<Index>, args...) 解析索引 In-Place-Konstruktion(args...) Objekt instanziiert Initialisierte Variant-Instanz
时序图:通过 ara::core::in_place_index_t 就地构造 Variant 值的典型流程。来源:[SWS_CORE_04032]
错误场景
在容错性方面,ara::core::in_place_index_t 表现出极高的鲁棒性。默认构造函数使用 noexcept 指定,并被视为异常安全(“exception safe”)[SWS_CORE_04032] 。该结构体既不存在错误码,也不存在定义的错误状态。
隐式转换中的错误使用通过规范为 explicit 在编译期被拒绝 [SWS_CORE_04032] 。若在执行 ara::core::Variant 的就地构造函数期间引发异常,该异常并非源自 ara::core::in_place_index_t,而是由所构造目标类型的错误行为所致。
本指南由 AI 基于 AUTOSAR 规范 R25-11 生成。
UML 类图 Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.
G
nara__core__in_place_index_t938
«struct»
in_place_index_t
+ in_place_index_t()
此版本没有元素数据
构造函数和析构函数 Default constructor
explicit in_place_index_t () noexcept=default;
方法文档
explicit in_place_index_t () noexcept=default;
Status: valid/unmigrated
Version: rel:R25-11#ed0aabbb
Versionshistorie & Revisions (1 transition, 8 revision)
Current State valid/unmigrated
Reason mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign 2026-08-13-status-backfill
Active Version AUTOSAR/AP/record/SWS_CORE_04032@rel:R25-11#ed0aabbb
Point-in-Time History:
Release:
R25-11 (Current / Active) R19-11 R20-11 R21-11 R22-11 R23-11 R24-11
View Snapshot
Recorded Revisions (8):
R25-11 rel:R25-11#8aa0e9952026-09-30 Inspect R19-11 rel:R19-11#1dfe84832026-10-14 Inspect R20-11 rel:R20-11#98f310882026-10-14 Inspect R21-11 rel:R21-11#98f310882026-10-14 Inspect R22-11 rel:R22-11#b23504bd2026-10-14 Inspect R23-11 rel:R23-11#b523cc942026-10-14 Inspect R24-11 rel:R24-11#a52ebef82026-10-14 Inspect R25-11 rel:R25-11#ed0aabbb2026-10-14 active Inspect
Historical Snapshot:
× Back to current
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
Date Actor Transition Reason / Rationale Campaign
2026-08-13 tool none → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record 2026-08-13-status-backfill
gemini-3.8-flash-low· 2026-10-13 · 德文原文