DEENESPTFRRUARHIKOZHNL

类 ara::core::Optional< T & >

[SWS_CORE_01150]

template <typename T> class Optional< T & > final {...};

Specialization of for type T&

Header-Datei#include "ara/core/optional.h"
Forwarding-Header#include "ara/core/core_fwd.h"
Scopenamespace ara::core

用户指南人工智能生成

封装对对象的可选引用,并在无需动态内存分配的情况下实现安全访问。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 7a73f15cddcd 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

封装对对象的可选引用,并在无需动态内存分配的情况下实现安全访问。

特化 ara::core::Optional<T &> 用作元素类型为 T & [SWS_CORE_01151] 的可选左值引用的类型安全容器。它允许在运行时重新绑定或重置引用,而无需动态内存分配 [SWS_CORE_01164]、[SWS_CORE_01165]。在通过解引用运算符或可能引发错误的访问方法 value() 进行任何访问之前,必须强制检查有效目标对象是否存在 [SWS_CORE_01172]、[SWS_CORE_01173]。

上下文

模板特化 ara::core::Optional<T &> 为可选左值引用提供了类型安全的容器。基础元素类型通过类型别名 value_type 指定为 T & [SWS_CORE_01151]。与值类型的主模板不同,此特化用作可重用、可重新绑定的引用(Rebindable Reference),它要么引用 T 类型的现有对象,要么表示未占用状态。它直接与调用的软件组件和引用的目标对象进行交互,而不占用动态内存。

生命周期

ara::core::Optional<T &> 的实例始终处于两个受到良好控制的状态之一:空(未占用)或已占用(引用对象)。空状态通过默认构造函数 [SWS_CORE_01152] 或使用 nullopt_t [SWS_CORE_01153] 初始化来进入。在构造时通过传递兼容的值或引用 [SWS_CORE_01156] 以及通过转换构造函数 [SWS_CORE_01157] 来绑定到引用。拷贝和移动构造函数会转移源容器的状态 [SWS_CORE_01154]、[SWS_CORE_01155]。

在运行时可以动态修改状态:赋值某个值或引用会将 Optional 重新绑定到传入的目标对象 [SWS_CORE_01162],这也可以通过其他 Optional 容器的赋值运算符 [SWS_CORE_01159]、[SWS_CORE_01160]、[SWS_CORE_01163] 或方法 emplace [SWS_CORE_01164] 来实现。通过调用 reset [SWS_CORE_01165] 或通过赋值 nullopt_t [SWS_CORE_01161] 可以转换为为空状态。此外,swap 允许对两个实例进行原子交换 [SWS_CORE_01166]。默认析构函数结束包装器实例的生命周期 [SWS_CORE_01158],但大概不会触及所引用的原始对象,因为引用在语义上并不确立所有权。 问题 Q-3ba25e19c4b098ed (未决)

diag_lifecycle Leer Leer (disengaged) Leer->Leer operator=(nullopt) reset() Belegt Belegt (engaged) Leer->Belegt Optional(u) emplace() operator=(u) Belegt->Leer reset() operator=(nullopt) Belegt->Belegt emplace() operator=(u)

状态图:ara::core::Optional<T &> 实例的状态与状态转换。来源:[SWS_CORE_01152]、[SWS_CORE_01153]、[SWS_CORE_01156]、[SWS_CORE_01161]、[SWS_CORE_01162]、[SWS_CORE_01164]、[SWS_CORE_01165]。

使用路径

典型的应用程序周期包括创建、验证以及对被引用目标的读访问或修改访问:

  1. 初始化:创建一个空实例 [SWS_CORE_01152] 或使用对现有对象的引用进行填充 [SWS_CORE_01156]。
  2. 状态检查:在解引用之前,调用方通过显式转换运算符 operator bool [SWS_CORE_01171] 或方法 has_value [SWS_CORE_01172] 检查引用的存在性。
  3. 访问:在确认存在引用的情况下,通过解引用运算符 operator* [SWS_CORE_01169]、[SWS_CORE_01170] 或箭头运算符 operator-> [SWS_CORE_01167]、[SWS_CORE_01168] 访问引用的对象。或者,value_or 返回引用的值或指定的默认值 [SWS_CORE_01175]。
  4. 重置:处理完成后,如果需要,可以通过 reset 显式移除引用 [SWS_CORE_01165]。
Nutzungsablauf von Optional<T &>调用方OptionalZielobjektOptional(ziel)Instanz erzeugthas_value()trueopthas_value() == trueoperator*()解引用T &reset()void

时序图:可选引用的初始化、验证和解引用的典型流程。来源:[SWS_CORE_01156]、[SWS_CORE_01165]、[SWS_CORE_01170]、[SWS_CORE_01172]。

错误场景

错误主要发生在对空实例进行过早或不允许的访问尝试时。如果在对象不包含值时调用 value(),则会触发 IsoStdBadOption-alAccessViolation 类型的违规 [SWS_CORE_01173]、[SWS_CORE_01174]。因此,与该类的大多数其他操作不同,value() 显式未被归类为异常安全(not exception safe)。

如果实例未持有引用,通过 operator* [SWS_CORE_01169]、[SWS_CORE_01170] 以及 operator-> [SWS_CORE_01167]、[SWS_CORE_01168] 进行的直接解引用也会记录类别 IsoStdBadOption-alAccessViolation 的违规。虽然这些运算符是用 noexcept 声明的,但它们的使用必须遵守存在有效引用这一前置条件。

本指南由 AI 系统基于 AUTOSAR Adaptive R25-11 的规范要求生成。

成员图

类图

Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.

G nara__core__Optional__T____62 Optional< T & > + Optional() + operator=() + ~Optional() + emplace() + reset() + swap() + has_value() + operator bool() + operator*() + Optional< T &() + value() + value_or()

详细视图

请在大纲中选择一个条目。

构造函数和析构函数

Optional 函数 6

≙ [optional]

重载 Optional 6
constexpr Optional () noexcept; SWS_CORE_01152
constexpr Optional (nullopt_t) noexcept; SWS_CORE_01153
constexpr Optional (const Optional &other) noexcept=default; SWS_CORE_01154
constexpr Optional (Optional &&other) noexcept=default; SWS_CORE_01155
template <typename U = T> explicit constexpr Optional (U &&u) noexcept; SWS_CORE_01156
template <typename U> explicit constexpr Optional (Optional< U > const &other) noexcept; SWS_CORE_01157
~Optional 函数

≙ [optional]

~Optional () noexcept=default;

方法

emplace 函数

≙ [optional]

template <typename U = T> constexpr Optional & emplace (U &&u) noexcept;
has_value 函数

≙ [optional]

constexpr bool has_value () const noexcept;
Optional< T & 函数 2

≙ [optional]

重载 Optional< T & 2
T const * operator-> () const noexcept; SWS_CORE_01167
T * operator-> () noexcept; SWS_CORE_01168
reset 函数

≙ [optional]

constexpr void reset () noexcept;
swap 函数

≙ [optional]

constexpr void swap (Optional &other) noexcept;
value 函数 2

≙ [optional]

重载 value 2
constexpr T & value (); SWS_CORE_01173
constexpr T const & value () const; SWS_CORE_01174
value_or 函数

≙ [optional]

template <typename U> constexpr T value_or (U &&u) const noexcept;

运算符

≙ [optional]

explicit constexpr operator bool () const noexcept;
operator* 函数 2

≙ [optional]

重载 * 2
constexpr T const & operator* () const noexcept; SWS_CORE_01169
constexpr T & operator* () noexcept; SWS_CORE_01170
operator= 函数 5

≙ [optional]

重载 = 5
constexpr Optional & operator= (const Optional &other) & noexcept=default; SWS_CORE_01159
constexpr Optional & operator= (Optional &&other) & noexcept=default; SWS_CORE_01160
constexpr Optional & operator= (nullopt_t) & noexcept; SWS_CORE_01161
template <typename U = T> constexpr Optional & operator= (U &&u) & noexcept; SWS_CORE_01162
template <typename U = T> Optional & operator= (const Optional< U > &other) & noexcept; SWS_CORE_01163

类型别名

value_type 类型别名

≙ [optional]

using value_type = T&;

方法文档

函数 Optional< T & [SWS_CORE_01167]

T const * operator-> () const noexcept;

As per corresponding usage in [optional]

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 89692a8124d3 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

模板类 ara::core::Optional<T &> 的成员访问运算符 operator-> 用于同步访问被引用对象的成员 [SWS_CORE_01167]。该函数在头文件 #include "ara/core/optional.h" 中定义,属于 ara::core::Optional<T &> 的作用域,且不应传入任何参数 [SWS_CORE_01167]。返回值是类型为 T const * 的指针,允许对底层目标对象进行直接读取访问 [SWS_CORE_01167]。因此,返回类型对应于指向常量数据的指针,从而禁止通过此运算符进行修改性访问。

关于错误处理,该方法被声明为 noexcept 并被归类为 exception safe [SWS_CORE_01167]。然而,如果实例不包含值(If *this does not contain a value),规范中记录的违规为 IsoStdBadOptionalAccessViolation [SWS_CORE_01167]。因此,在解引用之前,应用软件必须确保可选引用已有效赋值,以可靠地避免运行时的错误状态。

对于并发性和调用上下文,规范没有提及单独的保护机制;const 操作大概不提供针对并发修改的内部同步 [SWS_CORE_01167]。 问题 Q-0ebf3ed1284fc0c1 (未决)根据规范,常规行为遵循 C++ 标准中可选类型的相应用法(As per corresponding usage in [optional])[SWS_CORE_01167]。

本使用说明基于 AUTOSAR R25-11 规范自动生成。

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01167
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01167@rel:R25-11#62c44f0e
Content hash
62c44f0e
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01167
Status: valid/unmigrated Version: rel:R25-11#619d01d4 Versionshistorie & Revisions (1 transition, 3 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_01167@rel:R25-11#619d01d4
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#453ae4da2026-09-30
  • R24-11rel:R24-11#70a745e42026-10-14
  • R25-11rel:R25-11#619d01d42026-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

函数 Optional< T & [SWS_CORE_01168]

T * operator-> () noexcept;

As per corresponding usage in [optional]

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: f85c6d08317d 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

特化 ara::core::Optional<T &> 的重载运算符 operator-> 支持对封装引用的同步成员访问([SWS_CORE_01168])。该函数通过头文件 ara/core/optional.h 提供,不需要调用参数。调用时,它返回一个指向被引用目标对象的类型为 T * 的指针,从而可以直接寻址该实例的成员([SWS_CORE_01168])。其语义对应于 C++ 标准中 [optional] 的使用([SWS_CORE_01168])。

在故障安全性方面,该运算符被声明为 noexcept,并被归类为异常安全(“exception safe”)([SWS_CORE_01168])。如果实例不包含值(*this does not contain a value),则存在类别为 IsoStdBadOptionalAccessViolation 的访问冲突([SWS_CORE_01168])。理解:由于签名被声明为 noexcept,推测这种无效状态大概不会通过抛出常规 C++ 异常来处理,而是会导致标准化错误处理或程序中止。 问题 Q-c3ef91b84a00cae8 (未决)

作为调用条件,开发人员必须在执行前确保 Optional 对象确实包含值。在未事先检查占用状态的情况下进行不安全的访问违反了运算符的前提条件([SWS_CORE_01168])。

此文本由系统自动创建。专业陈述均有规范引文支持。

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01168
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01168@rel:R25-11#214a7c58
Content hash
214a7c58
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01168
Status: valid/unmigrated Version: rel:R25-11#df3c1201 Versionshistorie & Revisions (1 transition, 3 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_01168@rel:R25-11#df3c1201
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#62076e1a2026-09-30
  • R24-11rel:R24-11#3761249b2026-10-14
  • R25-11rel:R25-11#df3c12012026-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

函数 Optional [SWS_CORE_01152]

constexpr Optional () noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01152
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01152@rel:R25-11#73120bbc
Content hash
73120bbc
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01152
Status: valid/unmigrated Version: rel:R25-11#bd774096 Versionshistorie & Revisions (1 transition, 3 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_01152@rel:R25-11#bd774096
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#203f559e2026-09-30
  • R24-11rel:R24-11#5f8d3df42026-10-14
  • R25-11rel:R25-11#bd7740962026-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

函数 Optional [SWS_CORE_01153]

constexpr Optional (nullopt_t) noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01153
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01153@rel:R25-11#12ac69a2
Content hash
12ac69a2
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01153
Status: valid/unmigrated Version: rel:R25-11#a42355d6 Versionshistorie & Revisions (1 transition, 3 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_01153@rel:R25-11#a42355d6
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#d49495ac2026-09-30
  • R24-11rel:R24-11#4189d3352026-10-14
  • R25-11rel:R25-11#a42355d62026-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

函数 Optional [SWS_CORE_01154]

constexpr Optional (const Optional &other) noexcept=default;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01154
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01154@rel:R25-11#21bd0e1d
Content hash
21bd0e1d
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01154
Status: valid/unmigrated Version: rel:R25-11#6343a19e Versionshistorie & Revisions (1 transition, 3 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_01154@rel:R25-11#6343a19e
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#c9cbf44b2026-09-30
  • R24-11rel:R24-11#67a352912026-10-14
  • R25-11rel:R25-11#6343a19e2026-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

函数 Optional [SWS_CORE_01155]

constexpr Optional (Optional &&other) noexcept=default;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01155
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01155@rel:R25-11#9fb941bd
Content hash
9fb941bd
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01155
Status: valid/unmigrated Version: rel:R25-11#63fd67a5 Versionshistorie & Revisions (1 transition, 3 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_01155@rel:R25-11#63fd67a5
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#1cfb040f2026-09-30
  • R24-11rel:R24-11#4e8aeb8f2026-10-14
  • R25-11rel:R25-11#63fd67a52026-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

函数 Optional [SWS_CORE_01156]

template <typename U = T> explicit constexpr Optional (U &&u) noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01156
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01156@rel:R25-11#6eabdf10
Content hash
6eabdf10
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01156
Status: valid/unmigrated Version: rel:R25-11#20a661bc Versionshistorie & Revisions (1 transition, 3 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_01156@rel:R25-11#20a661bc
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#f57f8ec42026-09-30
  • R24-11rel:R24-11#e42ae9492026-10-14
  • R25-11rel:R25-11#20a661bc2026-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

函数 Optional [SWS_CORE_01157]

template <typename U> explicit constexpr Optional (Optional< U > const &other) noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01157
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01157@rel:R25-11#fecb0405
Content hash
fecb0405
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01157
Status: valid/unmigrated Version: rel:R25-11#9d72d212 Versionshistorie & Revisions (1 transition, 3 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_01157@rel:R25-11#9d72d212
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#818d85522026-09-30
  • R24-11rel:R24-11#4a2fbbd72026-10-14
  • R25-11rel:R25-11#9d72d2122026-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

函数 emplace [SWS_CORE_01164]

template <typename U = T> constexpr Optional & emplace (U &&u) noexcept;

As per corresponding usage in [optional]

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: eb9f72cc598f 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

特化 ara::core::Optional<T&> 的模板成员函数 emplace 用于在可选容器中赋值或设置引用([SWS_CORE_01164])。该函数通过头文件 #include "ara/core/optional.h" 定义([SWS_CORE_01164])。

用法与语义

调用同步进行,并接收类型为 U&&(默认为 U = T)的转发引用 u 作为参数([SWS_CORE_01164])。解释:实参 u 在此大概率被重新绑定到 Optional 中持有的引用,而不会构造新对象。 问题 Q-55c9eca385e9e496 (未决)作为返回值,emplace 返回对 Optional 实例本身的左值引用(Optional &),这允许操作链式调用([SWS_CORE_01164])。通过声明为 constexpr,该调用也可以在编译期常量表达式中求值([SWS_CORE_01164])。

错误处理与异常安全性

该操作被声明为 noexcept 并具有分类 exception safe([SWS_CORE_01164])。在规范摘要中未规定特定的错误码、DET 或 DEM 消息;排除了因 C++ 异常而失败的情况([SWS_CORE_01164])。

相互协作与区分

与针对值类型的 ara::core::Optional<T> 主模板变体不同——后者就地构造所包含的对象,返回引用 T&,且仅具有有条件的异常安全性(conditionally exception safe)或有条件 noexcept([SWS_CORE_01119]、[SWS_CORE_01120])——针对 Optional<T&> 的该重载保证严格的无异常性([SWS_CORE_01164])。模块的其他容器(例如 ara::core::Vector([SWS_CORE_01366])、ara::core::Map([SWS_CORE_01458])或 ara::core::Variant([SWS_CORE_01661]))也提供 emplace 方法,但具有独立的语义和不同的安全级别。

本使用说明基于 AUTOSAR Adaptive R25-11 规范自动生成。

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01164
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01164@rel:R25-11#8d88da15
Content hash
8d88da15
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01164
Status: valid/unmigrated Version: rel:R25-11#ae44b1d3 Versionshistorie & Revisions (1 transition, 3 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_01164@rel:R25-11#ae44b1d3
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#30e3d4342026-09-30
  • R24-11rel:R24-11#62874e892026-10-14
  • R25-11rel:R25-11#ae44b1d32026-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

函数 has_value [SWS_CORE_01172]

constexpr bool has_value () const noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01172
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01172@rel:R25-11#4f18d6ae
Content hash
4f18d6ae
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01172
Status: valid/unmigrated Version: rel:R25-11#401f0d0a Versionshistorie & Revisions (1 transition, 3 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_01172@rel:R25-11#401f0d0a
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#a395f6112026-09-30
  • R24-11rel:R24-11#fd763aff2026-10-14
  • R25-11rel:R25-11#401f0d0a2026-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

函数 operator bool [SWS_CORE_01171]

explicit constexpr operator bool () const noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01171
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01171@rel:R25-11#89009623
Content hash
89009623
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01171
Status: valid/unmigrated Version: rel:R25-11#35eaa065 Versionshistorie & Revisions (1 transition, 3 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_01171@rel:R25-11#35eaa065
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#f211fcbd2026-09-30
  • R24-11rel:R24-11#59297dd12026-10-14
  • R25-11rel:R25-11#35eaa0652026-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

函数 operator* [SWS_CORE_01169]

constexpr T const & operator* () const noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01169
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01169@rel:R25-11#a78b19f7
Content hash
a78b19f7
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01169
Status: valid/unmigrated Version: rel:R25-11#7af50405 Versionshistorie & Revisions (1 transition, 3 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_01169@rel:R25-11#7af50405
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#5244c30f2026-09-30
  • R24-11rel:R24-11#058fa3292026-10-14
  • R25-11rel:R25-11#7af504052026-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

函数 operator* [SWS_CORE_01170]

constexpr T & operator* () noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01170
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01170@rel:R25-11#642e2bba
Content hash
642e2bba
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01170
Status: valid/unmigrated Version: rel:R25-11#cf473125 Versionshistorie & Revisions (1 transition, 3 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_01170@rel:R25-11#cf473125
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#fbc1818d2026-09-30
  • R24-11rel:R24-11#036016592026-10-14
  • R25-11rel:R25-11#cf4731252026-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

函数 operator= [SWS_CORE_01159]

constexpr Optional & operator= (const Optional &other) & noexcept=default;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01159
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01159@rel:R25-11#2f87df75
Content hash
2f87df75
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01159
Status: valid/unmigrated Version: rel:R25-11#3efb9211 Versionshistorie & Revisions (1 transition, 3 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_01159@rel:R25-11#3efb9211
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#0ceb335f2026-09-30
  • R24-11rel:R24-11#7729a6cc2026-10-14
  • R25-11rel:R25-11#3efb92112026-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

函数 operator= [SWS_CORE_01160]

constexpr Optional & operator= (Optional &&other) & noexcept=default;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01160
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01160@rel:R25-11#ec952254
Content hash
ec952254
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01160
Status: valid/unmigrated Version: rel:R25-11#df5ae80f Versionshistorie & Revisions (1 transition, 3 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_01160@rel:R25-11#df5ae80f
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#a47c96572026-09-30
  • R24-11rel:R24-11#7fccea222026-10-14
  • R25-11rel:R25-11#df5ae80f2026-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

函数 operator= [SWS_CORE_01161]

constexpr Optional & operator= (nullopt_t) & noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01161
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01161@rel:R25-11#ce097c4b
Content hash
ce097c4b
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01161
Status: valid/unmigrated Version: rel:R25-11#47d11828 Versionshistorie & Revisions (1 transition, 3 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_01161@rel:R25-11#47d11828
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#224804b32026-09-30
  • R24-11rel:R24-11#07da73332026-10-14
  • R25-11rel:R25-11#47d118282026-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

函数 operator= [SWS_CORE_01162]

template <typename U = T> constexpr Optional & operator= (U &&u) & noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01162
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01162@rel:R25-11#7bac395c
Content hash
7bac395c
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01162
Status: valid/unmigrated Version: rel:R25-11#48bce027 Versionshistorie & Revisions (1 transition, 3 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_01162@rel:R25-11#48bce027
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#043f8bfa2026-09-30
  • R24-11rel:R24-11#e310521a2026-10-14
  • R25-11rel:R25-11#48bce0272026-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

函数 operator= [SWS_CORE_01163]

template <typename U = T> Optional & operator= (const Optional< U > &other) & noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01163
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01163@rel:R25-11#0152d8c5
Content hash
0152d8c5
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01163
Status: valid/unmigrated Version: rel:R25-11#13eb961a Versionshistorie & Revisions (1 transition, 3 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_01163@rel:R25-11#13eb961a
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#963c28f12026-09-30
  • R24-11rel:R24-11#5bc3f9cf2026-10-14
  • R25-11rel:R25-11#13eb961a2026-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

函数 reset [SWS_CORE_01165]

constexpr void reset () noexcept;

As per corresponding usage in [optional]

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: b70ef11c6c14 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

根据 [SWS_CORE_01165],特化 ara::core::Optional<T&> 的成员函数 reset 用于重置可选引用对象。它通过头文件 #include "ara/core/optional.h" 声明,不接收任何参数,也没有返回值(void)。作为 constexpr 函数,它也可以在编译时求值中使用;其执行同步进行。解释:根据在 [optional] 中使用的通用参考,该调用可能将实例置于无绑定引用的状态(disengaged),从而使该对象此后不再包含值。 问题 Q-edf521c7744139d2 (未决)

在错误处理方面,根据 [SWS_CORE_01165],该函数带有标识符 noexcept 并被归类为异常安全(“exception safe”)。因此调用不会抛出异常,也不会报告错误代码;针对该函数,有效载荷中未定义特定的 DET 或 DEM 消息。

在模块上下文中,该实现与根据 [SWS_CORE_01136] 的通用模板类 ara::core::Optional 不同,后者的 reset 方法未声明为 constexpr。模块中针对 ara::core::Bitset 存在其他 reset 函数,其中 reset() 根据 [SWS_CORE_01727] 返回对对象的引用,或者根据 [SWS_CORE_01728] 指定位置返回 ara::core::Result 并在索引无效时引发 IsoStdOutOfRangeViolation。

此文本由 AI 系统基于规范数据生成。

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01165
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01165@rel:R25-11#5dfad2c6
Content hash
5dfad2c6
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01165
Status: valid/unmigrated Version: rel:R25-11#96b9362b Versionshistorie & Revisions (1 transition, 3 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_01165@rel:R25-11#96b9362b
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#c553061a2026-09-30
  • R24-11rel:R24-11#a55359f52026-10-14
  • R25-11rel:R25-11#96b9362b2026-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

函数 swap [SWS_CORE_01166]

constexpr void swap (Optional &other) noexcept;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01166
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01166@rel:R25-11#08af7eab
Content hash
08af7eab
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01166
Status: valid/unmigrated Version: rel:R25-11#47897cb1 Versionshistorie & Revisions (1 transition, 3 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_01166@rel:R25-11#47897cb1
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#036ffd582026-09-30
  • R24-11rel:R24-11#c68cc8362026-10-14
  • R25-11rel:R25-11#47897cb12026-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

函数 value [SWS_CORE_01173]

constexpr T & value ();

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitnot exception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01173
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01173@rel:R25-11#72184432
Content hash
72184432
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01173
Status: valid/unmigrated Version: rel:R25-11#bb97e429 Versionshistorie & Revisions (1 transition, 3 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_01173@rel:R25-11#bb97e429
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#a59124572026-09-30
  • R24-11rel:R24-11#c5e7fb242026-10-14
  • R25-11rel:R25-11#bb97e4292026-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

函数 value [SWS_CORE_01174]

constexpr T const & value () const;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitnot exception safe
Verletzungen (Violations)IsoStdBadOption- If *this does not contain a value alAccessViolation

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

Record
AUTOSAR/AP/record/SWS_CORE_01174
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01174@rel:R25-11#bc600713
Content hash
bc600713
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01174
Status: valid/unmigrated Version: rel:R25-11#3d7b55ac Versionshistorie & Revisions (1 transition, 3 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_01174@rel:R25-11#3d7b55ac
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#ded2d5c12026-09-30
  • R24-11rel:R24-11#9a78cd172026-10-14
  • R25-11rel:R25-11#3d7b55ac2026-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

函数 value_or [SWS_CORE_01175]

template <typename U> constexpr T value_or (U &&u) const noexcept;

As per corresponding usage in [optional]

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 6b4e9a7193a7 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

特化 ara::core::Optional<T&> 的成员函数 value_or 通过头文件 #include "ara/core/optional.h" 提供 [SWS_CORE_01175]。作为模板函数,它接收参数 U&& u 作为替代值,并同步返回类型为 T 的结果值。解释:根据规范说明“As per corresponding usage in [optional]”,如果对象已填充,该函数应该返回引用所持有的值,否则返回后备值 u。 问题 Q-c050380198abf06b (未决)

对于错误处理,规范保证了完全的异常安全性(exception safe),并将该方法声明为 noexcept [SWS_CORE_01175]。该操作未规定错误码,也未规定向错误或诊断监视器发出通知。由于该成员函数还被限定为 constexpr 以及 const,因此它也可以在编译时常量表达式中求值,而无需修改对象 [SWS_CORE_01175]。

在模块 core 的上下文中,该函数与非引用类型的通用重载密切相关。虽然 ara::core::Optional<T&> 的 [SWS_CORE_01175] 被声明为 exception safe,但规范将主模板 ara::core::Optional 的对应变体——即 const 左值重载 [SWS_CORE_01134] 和右值重载 [SWS_CORE_01135]——分别归类为 not exception safe。

本使用说明由 AI 基于规范创建。

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01175
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01175@rel:R25-11#b4f6f793
Content hash
b4f6f793
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01175
Status: valid/unmigrated Version: rel:R25-11#b15a3240 Versionshistorie & Revisions (1 transition, 3 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_01175@rel:R25-11#b15a3240
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#07a50f3f2026-09-30
  • R24-11rel:R24-11#b275cdd32026-10-14
  • R25-11rel:R25-11#b15a32402026-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

函数 ~Optional [SWS_CORE_01158]

~Optional () noexcept=default;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_01158
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01158@rel:R25-11#9fb36b2d
Content hash
9fb36b2d
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01158
Status: valid/unmigrated Version: rel:R25-11#9f329d75 Versionshistorie & Revisions (1 transition, 3 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_01158@rel:R25-11#9f329d75
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#5583615b2026-09-30
  • R24-11rel:R24-11#8b55e5d62026-10-14
  • R25-11rel:R25-11#9f329d752026-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

类型别名文档

类型别名 value_type [SWS_CORE_01151]

using value_type = T&;

As per corresponding usage in [optional]

Header-Datei#include "ara/core/optional.h"
Scopeclass ara::core::Optional< T & >
Symbolvalue_type

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

Record
AUTOSAR/AP/record/SWS_CORE_01151
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_01151@rel:R25-11#9de319de
Content hash
9de319de
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_01151
Status: valid/unmigrated Version: rel:R25-11#53609b21 Versionshistorie & Revisions (1 transition, 3 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_01151@rel:R25-11#53609b21
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#ec6b63872026-09-30
  • R24-11rel:R24-11#03a4e1d12026-10-14
  • R25-11rel:R25-11#53609b212026-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