DEENESPTFRRUARHIKOZHNL

类 ara::core::MemoryResource

[SWS_CORE_06500] Upstream: RS_AP_00130

class MemoryResource {...};

Implementation of std::pmr::memory_resource type from [mem.res.class]

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

用户指南人工智能生成

用作无异常内存分配和释放的基础接口。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: efd95fd8a941 来源 未决问题(2)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

用作无异常内存分配和释放的基础接口。

该类为多态内存资源提供了抽象基础接口,该接口参考了 C++ 标准接口。它通过非虚接口模式(Non-Virtual-Interface)将分配和释放请求转发给派生的资源类 [SWS_CORE_06503]。与 C++ 标准不同,所有接口函数均声明为异常安全,因此内存错误不是通过异常指示,而是通过返回空指针来指示 [SWS_CORE_06566]。此外,分配和释放过程在默认情况下设计为非线程安全。

上下文

类 ara::core::MemoryResource 在 AUTOSAR Adaptive Platform(模块 core)中提供了内存管理的抽象基础接口,该接口借鉴了 C++ 标准类型 std::pmr::memory_resource。它用作可替换分配策略的通用基础,并将调用方数据结构与内存提供的具体机制解耦。作为与 ISO C++ 标准的主要区别,AUTOSAR 规范完全放弃了动态异常,并为所有操作制定了严格的 noexcept 保证 [SWS_CORE_06501]。

该架构遵循非虚接口模式(NVI):公共非虚成员函数为调用方定义固定接口,而实际行为必须通过私有纯虚成员函数在派生类中实现。解释:具体内存资源派生自 ara::core::MemoryResource 并重写私有基础接口 do_allocate [SWS_CORE_06566]、do_deallocate [SWS_CORE_06567] 以及 do_is_equal [SWS_CORE_06568],以提供特定于应用程序的缓冲区或内存池管理。 问题 Q-d09d47b0a8f6b822 (未决)

生命周期

特化的实例化通过指定为 noexcept=default 的无参默认构造函数进行 [SWS_CORE_06501]。同样提供 noexcept 拷贝构造函数 [SWS_CORE_06502] 和 noexcept 拷贝赋值运算符 [SWS_CORE_06507]。作为对 C++ 标准的补充,AUTOSAR 显式定义了一个移动构造函数 [SWS_CORE_06574] 和一个移动赋值运算符 [SWS_CORE_06575],两者均被指定为 noexcept=default。

多态实例的生命周期由声明为异常安全的虚析构函数保护 [SWS_CORE_06506]。关于并发性需要注意的是,析构函数以及分配和释放函数 allocate [SWS_CORE_06503] 和 deallocate [SWS_CORE_06504] 均被指定为非线程安全。解释:对于线程安全的分配和释放,推测应由上层同步机制或专门的子类负责,因为基础方法被指定为非线程安全。 问题 Q-adac4b6cf6e0db7c (未决)相比之下,通过 is_equal 进行的相等性检查显式设计为线程安全 [SWS_CORE_06505]。

使用路径

内存管理的主要流程包括通过公共 NVI 接口进行内存块的请求、可选的同一性检查以及随后的释放:

  • 内存分配:调用方通过指定字节大小和可选的对齐方式来调用 allocate [SWS_CORE_06503]。该方法在内部委托给具体类 [SWS_CORE_06566] 的私有纯虚函数 do_allocate。
  • 相等性检查:为了确定两个内存资源是否彼此等价以及是否可以通过另一个内存资源释放其中一个的内存,用户调用 is_equal [SWS_CORE_06505],该方法委托给 do_is_equal [SWS_CORE_06568]。
  • 内存释放:使用完毕后,通过指定指针、字节大小和对齐方式通过 deallocate 归还该内存块 [SWS_CORE_06504],从而内部转发给 do_deallocate [SWS_CORE_06567]。
内存分配与释放时的 NVI 调用委托调用方MemoryResourceKonkreteResourceUse Case: Speicherallokationallocate(bytes, alignment)do_allocate(bytes, alignment)altAllokation erfolgreichSpeicherzeigerSpeicherzeiger pAllokation fehlgeschlagennullptrnullptrUse Case: Speicherfreigabedeallocate(p, bytes, alignment)do_deallocate(p, bytes, alignment)返回返回

时序图:分配和释放时通过 NVI 模式的调用委托。来源:[SWS_CORE_06503],[SWS_CORE_06504],[SWS_CORE_06566],[SWS_CORE_06567]

错误场景

该类的一个核心特征是完全摒弃异常。ISO C++ 标准在耗尽情况下提供 std::bad_alloc 类型的异常,而 AUTOSAR 对此进行了有针对性的偏离:如果 allocate 或 do_allocate 中的分配失败,函数强制返回 nullptr [SWS_CORE_06503],[SWS_CORE_06566]。通过 allocate 上的 [[nodiscard]] 属性,提示调用方始终接收返回值并在访问前检查有效性。

对于释放操作 deallocate 和 do_deallocate,归还内存时的任何错误都将被静默忽略 [SWS_CORE_06504],[SWS_CORE_06567]。既不抛出异常也不返回错误代码,这有助于满足自适应平台上下文中的严格实时性和安全性要求。

本文由 AI 策展,完全基于 AUTOSAR Adaptive Platform R25-11 规范。

成员图

构造函数和析构函数

2

运算符

1

类图

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

G nara__core__MemoryResource130 MemoryResource + MemoryResource() + operator=() + ~MemoryResource() + allocate() + deallocate() + is_() + do_() nara__core__MonotonicBufferResource118 MonotonicBufferResource nara__core__MonotonicBufferResource118->nara__core__MemoryResource130 nara__core__SynchronizedPoolResource481 SynchronizedPoolResource nara__core__SynchronizedPoolResource481->nara__core__MemoryResource130 nara__core__UnsynchronizedPoolResource176 UnsynchronizedPoolResource nara__core__UnsynchronizedPoolResource176->nara__core__MemoryResource130

详细视图

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

构造函数和析构函数

except for the following deviations: 1. The function is noexcept ≙ [mem.res]

重载 MemoryResource 3
MemoryResource () noexcept=default; SWS_CORE_06501
MemoryResource (const MemoryResource &other) noexcept=default; SWS_CORE_06502
MemoryResource (MemoryResource &&other) noexcept=default; SWS_CORE_06574

except for the following deviations: 1. The function is noexcept ≙ [mem.res]

virtual ~MemoryResource () noexcept;

方法

allocate 函数

except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception ≙ std::bad_alloc

[[nodiscard]] void * allocate (std::size_t bytes, std::size_t alignment=alignof(std::max_align_t)) noexcept;
deallocate 函数

except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored ≙ [mem.res]

void deallocate (void *p, std::size_t bytes, std::size_t alignment=max_align) noexcept;
do_ 函数 3

in [15] except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception ≙ std::bad_alloc

重载 do_ 3
virtual void * do_allocate (std::size_t bytes, std::size_t alignment) noexcept=0; SWS_CORE_06566
virtual void do_deallocate (void *p, std::size_t bytes, std::size_t alignment) noexcept=0; SWS_CORE_06567
virtual bool do_is_equal (const MemoryResource &other) const noexcept=0; SWS_CORE_06568
is_ 函数

≙ [mem.res]

bool is_equal (const MemoryResource &other) const noexcept;

运算符

operator= 函数 2

except for the following deviations: 1. The function is noexcept ≙ [mem.res]

重载 = 2
MemoryResource & operator= (const MemoryResource &other) noexcept=default; SWS_CORE_06507
MemoryResource & operator= (MemoryResource &&other) noexcept=default; SWS_CORE_06575

方法文档

函数 MemoryResource [SWS_CORE_06501]

MemoryResource () noexcept=default;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06501
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06501@rel:R25-11#f4874a13
Content hash
f4874a13
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06501
Status: valid/unmigrated Version: rel:R25-11#b9f1b788 Versionshistorie & Revisions (1 transition, 4 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_06501@rel:R25-11#b9f1b788
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#9befd4042026-09-30
  • R23-11rel:R23-11#f033a21e2026-10-14
  • R24-11rel:R24-11#fd91462c2026-10-14
  • R25-11rel:R25-11#b9f1b7882026-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

函数 MemoryResource [SWS_CORE_06502] Upstream: RS_AP_00130

MemoryResource (const MemoryResource &other) noexcept=default;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06502
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06502@rel:R25-11#6b53581c
Content hash
6b53581c
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06502
Status: valid/unmigrated Version: rel:R25-11#c99831b9 Versionshistorie & Revisions (1 transition, 4 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_06502@rel:R25-11#c99831b9
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#54ec446b2026-09-30
  • R23-11rel:R23-11#0d9d49792026-10-14
  • R24-11rel:R24-11#95d8ae9e2026-10-14
  • R25-11rel:R25-11#c99831b92026-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

函数 MemoryResource [SWS_CORE_06574] Upstream: RS_AP_00145

MemoryResource (MemoryResource &&other) noexcept=default;

[AUTOSAR defined] not present in ISO-14882. Move constructor

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe

Parameter (in)

ParameterBeschreibung
otherother MemoryResource to move from

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

Record
AUTOSAR/AP/record/SWS_CORE_06574
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06574@rel:R25-11#0bed1480
Content hash
0bed1480
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06574
Status: valid/unmigrated Version: rel:R25-11#95490182 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_06574@rel:R25-11#95490182
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#265cf3bf2026-09-30
  • R24-11rel:R24-11#ab47979b2026-10-14
  • R25-11rel:R25-11#954901822026-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

函数 allocate [SWS_CORE_06503]

[[nodiscard]] void * allocate (std::size_t bytes, std::size_t alignment=alignof(std::max_align_t)) noexcept;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception

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

类 ara::core::MemoryResource 的成员函数 allocate 用于分配具有指定字节大小和对齐方式的线性内存 [SWS_CORE_06503]。它参考了 C++ 标准接口 [mem.res],但在异常处理方面存在显著差异 [SWS_CORE_06503]。

用法与参数

该调用通过参数 bytes(要请求的字节数)和可选的 alignment(默认设置为 alignof(std::max_align_t))同步进行 [SWS_CORE_06503]。返回值带有属性 [[nodiscard]],因此调用者必须强制评估返回的 void* 类型指针 [SWS_CORE_06503]。

错误处理与异常安全性

与标准行为相反,该函数在出错时不会抛出类型为 std::bad_alloc 的异常,而是被声明为 noexcept 且被视为具有异常安全性(exception safe)[SWS_CORE_06503]:

  • 成功:根据 [mem.res] [SWS_CORE_06503] 返回指向已分配内存区域的有效指针。
  • 失败:如果内存分配失败,该函数将返回 nullptr 作为替代 [SWS_CORE_06503]。因此,调用者必须始终显式检查结果是否为空指针。

并发性与交互

该函数被指定为非线程安全(not thread-safe)[SWS_CORE_06503]。因此,在 MemoryResource 的同一实例上进行并发调用需要由调用者进行外部同步。这种容错且无异常的模式在 AUTOSAR Adaptive 的其他内存组件中也始终如一:例如 ara::core::PolymorphicAllocator::allocate 采用相同的无异常方法 [SWS_CORE_06547],特殊实例 NullMemoryResource 也通过返回 nullptr 来指示内存耗尽 [SWS_CORE_06563]。

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

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

Rückgabewert

TypBeschreibung
void *• If successful: As per corresponding usage in [mem.res] • If unsuccessful: the returned pointer shall be nullptr

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

Record
AUTOSAR/AP/record/SWS_CORE_06503
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06503@rel:R25-11#89c006b3
Content hash
89c006b3
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06503
Status: valid/unmigrated Version: rel:R25-11#8ff560e7 Versionshistorie & Revisions (1 transition, 4 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_06503@rel:R25-11#8ff560e7
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#1fa3c3192026-09-30
  • R23-11rel:R23-11#a898640f2026-10-14
  • R24-11rel:R24-11#f8eb1c392026-10-14
  • R25-11rel:R25-11#8ff560e72026-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

函数 deallocate [SWS_CORE_06504]

void deallocate (void *p, std::size_t bytes, std::size_t alignment=max_align) noexcept;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored

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

类 ara::core::MemoryResource 的函数 deallocate 用于根据 [SWS_CORE_06504] 释放内存区域。其使用原则上遵循 [mem.res] 中的标准行为,但存在特定差异。该调用通过签名 void deallocate(void *p, std::size_t bytes, std::size_t alignment=max_align) noexcept 同步进行,其中传递了指向待释放块的指针 p、大小 bytes 以及可选的对齐方式 [SWS_CORE_06504]。

关于错误行为,该函数被指定为 noexcept 且具备异常安全性(exception safe)[SWS_CORE_06504]。如果释放失败,错误将被静默忽略(errors will be silently ignored)[SWS_CORE_06504]。既不抛出异常,也不通过 DET 或 DEM 输出错误消息。

关于并发性,该函数被明确归类为非线程安全(not thread-safe)[SWS_CORE_06504]。因此,对同一资源实例的并发访问必须由调用者在外部进行同步。

在与分配器概念的协作中,该函数对应于来自 [SWS_CORE_06548] 的类 ara::core::PolymorphicAllocator 的类型化接口 deallocate,后者在 noexcept 和静默错误处理方面具有类似的差异。

本使用说明由 AI 管理助手自动创建,且完全基于 AUTOSAR R25-11 的规范数据。

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06504
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06504@rel:R25-11#1f865a36
Content hash
1f865a36
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06504
Status: valid/unmigrated Version: rel:R25-11#6dfbadd7 Versionshistorie & Revisions (1 transition, 4 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_06504@rel:R25-11#6dfbadd7
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#9fe074b52026-09-30
  • R23-11rel:R23-11#99cc78692026-10-14
  • R24-11rel:R24-11#8ebb7f8c2026-10-14
  • R25-11rel:R25-11#6dfbadd72026-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

函数 do_ [SWS_CORE_06566]

virtual void * do_allocate (std::size_t bytes, std::size_t alignment) noexcept=0;

As per corresponding usage in [mem.res] in [15] except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception

Literaturverzeichnis SWS Core: [15] ISO/IEC 14882:2020, Programming languages – C++ – www.iso.org

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

类 ara::core::MemoryResource 的纯虚方法 do_allocate 用于分配具有指定字节大小和对齐方式的内存块 [SWS_CORE_06566]。它接受字节数(bytes)以及所需的对齐方式(alignment)作为参数。分配成功时,它会同步返回一个类型为 void * 的指向保留内存区域的指针 [SWS_CORE_06566]。

在错误处理方面,该函数特意偏离了常规 C++ 标准:它被声明为 noexcept,失败时不抛出 std::bad_alloc 异常,而是返回 nullptr [SWS_CORE_06566]。因此,调用方必须始终检查分配结果是否为空指针。

关于并发性,该方法被规范为 not thread-safe [SWS_CORE_06566]。如果派生实现未提供自身保护,则通过同一实例的并发调用需要外部同步。由于其私有可见性,用户的调用通常可能通过基类的上层接口间接进行。 问题 Q-5cbdabf121ed4550 (未决)

在内存管理的协同工作中,该方法构成了 do_deallocate 的直接对应部分,后者负责释放已分配的内存并静默忽略错误 [SWS_CORE_06567]。此外,比较函数 do_is_equal 检查两个资源实例在分配和释放方面是否彼此兼容 [SWS_CORE_06568]。

本使用说明基于规范自动生成。

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe
Sichtbarkeitprivate

Rückgabewert

TypBeschreibung
void *• If successful: As per corresponding usage in [mem.res] • If unsuccessful: the returned pointer shall be nullptr

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

Record
AUTOSAR/AP/record/SWS_CORE_06566
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06566@rel:R25-11#b57e6fcc
Content hash
b57e6fcc
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06566
Status: valid/unmigrated Version: rel:R25-11#f000b35f 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_06566@rel:R25-11#f000b35f
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#b88f78552026-09-30
  • R24-11rel:R24-11#1a8107de2026-10-14
  • R25-11rel:R25-11#f000b35f2026-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

函数 do_ [SWS_CORE_06567]

virtual void do_deallocate (void *p, std::size_t bytes, std::size_t alignment) noexcept=0;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored

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

类 ara::core::MemoryResource 的纯虚成员函数 do_deallocate(在 ara/core/memory_resource.h 中声明)根据 [SWS_CORE_06567] 用于释放先前保留的内存。它接收指向内存区域的指针 p 以及其大小 bytes 和所需的对齐方式 alignment。其语义原则上符合 C++ 标准 [mem.res],但具有两个显著的 Adaptive 专有偏差 [SWS_CORE_06567]。

首先,该函数被声明为 noexcept 并保证异常安全性(exception safe)[SWS_CORE_06567]。其次,释放期间的任何错误都会被静默忽略,从而使失败的操作既不能触发错误消息,也不能中断程序流 [SWS_CORE_06567]。

关于并发性,do_deallocate 被规范为 not thread-safe 且具有 private 可见性 [SWS_CORE_06567]。作为多态内存资源的实现细节,它大概会通过上层公共调用接口同步执行。 问题 Q-3f97e122ee7fb281 (未决)对同一资源的并发释放必须由派生类在需要时独立进行同步。

在模块 core 中,该函数与分配 do_allocate [SWS_CORE_06566] 形成对应,后者在出错时提供 nullptr 而非异常。与其他资源的比较通过方法 do_is_equal [SWS_CORE_06568] 进行,与释放操作相反,该方法被显式定义为 thread-safe。

本使用说明根据 AUTOSAR R25-11 的规范自动生成。

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe
Sichtbarkeitprivate

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

Record
AUTOSAR/AP/record/SWS_CORE_06567
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06567@rel:R25-11#81538850
Content hash
81538850
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06567
Status: valid/unmigrated Version: rel:R25-11#d951e36f 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_06567@rel:R25-11#d951e36f
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#7bf9805c2026-09-30
  • R24-11rel:R24-11#3e71af902026-10-14
  • R25-11rel:R25-11#d951e36f2026-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

函数 do_ [SWS_CORE_06568]

virtual bool do_is_equal (const MemoryResource &other) const noexcept=0;

As per corresponding usage in [mem.res]

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

纯虚成员函数 do_is_equal 在头文件 #include "ara/core/memory_resource.h" 中于 ara::core::MemoryResource 的命名空间内声明([SWS_CORE_06568])。根据 C++ 规范 [mem.res],它用于同步比较当前内存资源与传入的引用 const MemoryResource &other 是否相等([SWS_CORE_06568])。由于该方法被定义为具有私有可见性(private),其调用作为实现细节大概会通过类 ara::core::MemoryResource 的公共接口多态地处理([SWS_CORE_06568])。 问题 Q-cbe02f652b43d6ec (未决)

关于执行和错误安全性,do_is_equal 被声明为 exception safe 以及 noexcept([SWS_CORE_06568])。因此,它在任何情况下均不得抛出异常,并直接通过布尔返回值指示结果([SWS_CORE_06568])。此外,该方法被规范为 thread-safe,因此派生实现即使在并发比较时也必须保证线程安全性([SWS_CORE_06568])。

在与内存管理的其他虚方法协同工作中,do_is_equal 完善了派生资源类定制点的三元组([SWS_CORE_06568])。内存分配 do_allocate 在出错时提供 nullptr([SWS_CORE_06566]),而 do_deallocate 静默忽略错误([SWS_CORE_06567]),与 do_is_equal 不同的是,这两个函数都被指定为非线程安全(not thread-safe)([SWS_CORE_06566]、[SWS_CORE_06567])。这强调了对 do_is_equal 确保并发资源安全比较的特殊要求([SWS_CORE_06568])。

本段文本由 AI 生成,用作基于 AUTOSAR 规范的使用说明。

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe
Sichtbarkeitprivate

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

Record
AUTOSAR/AP/record/SWS_CORE_06568
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06568@rel:R25-11#77e50421
Content hash
77e50421
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06568
Status: valid/unmigrated Version: rel:R25-11#2eae7169 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_06568@rel:R25-11#2eae7169
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#6efe7dbb2026-09-30
  • R24-11rel:R24-11#111ffd482026-10-14
  • R25-11rel:R25-11#2eae71692026-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

函数 is_ [SWS_CORE_06505]

bool is_equal (const MemoryResource &other) const noexcept;

As per corresponding usage in [mem.res]

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06505
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06505@rel:R25-11#d535ef6e
Content hash
d535ef6e
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06505
Status: valid/unmigrated Version: rel:R25-11#fe89774e Versionshistorie & Revisions (1 transition, 4 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_06505@rel:R25-11#fe89774e
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#1cb798172026-09-30
  • R23-11rel:R23-11#f33063dc2026-10-14
  • R24-11rel:R24-11#657307fe2026-10-14
  • R25-11rel:R25-11#fe89774e2026-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_06507] Upstream: RS_AP_00130

MemoryResource & operator= (const MemoryResource &other) noexcept=default;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06507
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06507@rel:R25-11#0ff1d8e4
Content hash
0ff1d8e4
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06507
Status: valid/unmigrated Version: rel:R25-11#63abe892 Versionshistorie & Revisions (1 transition, 4 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_06507@rel:R25-11#63abe892
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#653993ea2026-09-30
  • R23-11rel:R23-11#af6672232026-10-14
  • R24-11rel:R24-11#85add1f52026-10-14
  • R25-11rel:R25-11#63abe8922026-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_06575] Upstream: RS_AP_00145

MemoryResource & operator= (MemoryResource &&other) noexcept=default;

[AUTOSAR defined] not present in ISO-14882. Move assignment operator

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe

Parameter (in)

ParameterBeschreibung
otherother MemoryResource to move from

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

Record
AUTOSAR/AP/record/SWS_CORE_06575
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06575@rel:R25-11#1a84445b
Content hash
1a84445b
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06575
Status: valid/unmigrated Version: rel:R25-11#8fb64462 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_06575@rel:R25-11#8fb64462
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#948a97b32026-09-30
  • R24-11rel:R24-11#617a865d2026-10-14
  • R25-11rel:R25-11#8fb644622026-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

函数 ~MemoryResource [SWS_CORE_06506]

virtual ~MemoryResource () noexcept;

As per corresponding usage in [mem.res] except for the following deviations: 1. The function is noexcept

Header-Datei#include "ara/core/memory_resource.h"
Scopeclass ara::core::MemoryResource
Exception-Sicherheitexception safe
Thread-Sicherheitnot thread-safe

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

Record
AUTOSAR/AP/record/SWS_CORE_06506
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_06506@rel:R25-11#83afe7bd
Content hash
83afe7bd
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_06506
Status: valid/unmigrated Version: rel:R25-11#2e224948 Versionshistorie & Revisions (1 transition, 4 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_06506@rel:R25-11#2e224948
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#1cb788282026-09-30
  • R23-11rel:R23-11#2af784a02026-10-14
  • R24-11rel:R24-11#5a037c852026-10-14
  • R25-11rel:R25-11#2e2249482026-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