DEENESPTFRRUARHIKOZHNL

结构体 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"
Scopenamespace ara::core

用户指南人工智能生成

用作根据索引在 Variant 中直接就地构造值的标签类型。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 39c809af4202 来源 未决问题(2)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

用作根据索引在 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 值Anwenderin_place_index_t<Index>VariantZielobjektexplicit in_place_index_t()Tag-InstanzVariant(in_place_index_t<Index>, args...)解析索引In-Place-Konstruktion(args...)Objekt instanziiertInitialisierte 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;

方法文档

函数 in_place_index_t [SWS_CORE_04032] Upstream: RS_AP_00130

explicit in_place_index_t () noexcept=default;

Default constructor

Header-Datei#include "ara/core/utility.h"
Scopestruct ara::core::in_place_index_t
Exception-Sicherheitexception safe

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CORE_04032
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_04032@rel:R25-11#ae7d34ab
Content hash
ae7d34ab
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_04032
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:
Recorded Revisions (8):
  • R25-11rel:R25-11#8aa0e9952026-09-30
  • R19-11rel:R19-11#1dfe84832026-10-14
  • R20-11rel:R20-11#98f310882026-10-14
  • R21-11rel:R21-11#98f310882026-10-14
  • R22-11rel:R22-11#b23504bd2026-10-14
  • R23-11rel:R23-11#b523cc942026-10-14
  • R24-11rel:R24-11#a52ebef82026-10-14
  • R25-11rel:R25-11#ed0aabbb2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill