Manages polymorphic memory allocation for objects and containers via replaceable memory resources.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 4f3088ca1f09ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Manages polymorphic memory allocation for objects and containers via replaceable memory resources.
The template class encapsulates memory-resource-based dynamic allocation for adaptive applications and containers as a completely exception-free implementation of polymorphic allocators [SWS_CORE_06541]. For flexible control of the object lifecycle, the instance delegates all memory requests to an exchangeable memory resource, where failed allocations deterministically return null pointers instead of C++ exceptions [SWS_CORE_06547]. As an essential functional constraint, regular copy assignment is explicitly prevented, while failed deallocation operations during ongoing operation are always silently ignored.
Context
The template class ara::core::PolymorphicAllocator implements the interface for stateful, polymorphic memory allocation in AUTOSAR Adaptive according to the C++ standard pattern and defines the underlying element type value_type[SWS_CORE_06572]. As an adapter, it mediates between calling components—such as containers or application structures—and a concrete memory resource. Via the method resource(), the pointer to the utilized MemoryResource can be queried at any time [SWS_CORE_06557]. Through this encapsulation, the request for memory is semantically decoupled from the concrete implementation of memory management.
Instances of the allocator are constructed either by default [SWS_CORE_06541] or with a pointer to a specific MemoryResource[SWS_CORE_06542]. Since the allocator merely references the memory resource, responsibility for its lifetime presumably lies with the caller. Question Q-adde89798a03cf8b (open) In addition to the regular copy constructor [SWS_CORE_06543], a converting constructor permits initialization from allocators for other element types U[SWS_CORE_06544].
With respect to ownership transfers, the regular copy assignment operator is deleted (=delete) [SWS_CORE_06545]. In contrast, AUTOSAR explicitly defines a move constructor [SWS_CORE_06546] and a default move assignment operator [SWS_CORE_00066]. During container copy operations, the method select_on_container_copy_construction() creates a corresponding allocator instance [SWS_CORE_06573].
Regarding concurrency, the default and converting constructors as well as the query of the memory resource are specified as thread-safe ([SWS_CORE_06541], [SWS_CORE_06542], [SWS_CORE_06544], [SWS_CORE_06557]). In contrast, move operations ([SWS_CORE_06546]), copy selections ([SWS_CORE_06573]), and all allocation, construction, and deallocation operations are declared as non-thread-safe.
Usage Path
The regular flow comprises memory provision, object construction, and their subsequent destruction and deallocation:
Memory allocation: Raw memory for n objects of type Tp is requested using allocate()[SWS_CORE_06547]. Alternatively, allocate_bytes() is available for byte-precise allocation with alignment [SWS_CORE_06549], as is the template allocate_object() for typed allocations [SWS_CORE_06551].
Object initialization: The method construct() creates objects in the previously allocated memory area [SWS_CORE_06555]. As a combined operation, new_object() provides allocation and in-place construction in a single call [SWS_CORE_06553].
The class differs from the ISO C++ standard in key error handling mechanisms in order to satisfy strict requirements for exception-free systems:
Absence of exceptions during allocation: All allocation methods (allocate()[SWS_CORE_06547], allocate_bytes()[SWS_CORE_06549], and allocate_object()[SWS_CORE_06551]) are noexcept. If a memory reservation fails, a nullptr is returned instead of an exception. The caller is likely required to validate the pointer prior to further use. Question Q-a12cbeeba5edd1d0 (open)
Conditional exception safety: Construction and destruction routines (construct()[SWS_CORE_06555], destroy()[SWS_CORE_06556], new_object()[SWS_CORE_06553], and delete_object()[SWS_CORE_06554]) are conditionally noexcept, depending on std::is_nothrow_constructible or std::is_nothrow_destructible of the affected types. If new_object() fails, nullptr is returned as well [SWS_CORE_06553].
Error suppression during deallocation: If deallocation operations fail, any errors that occurred in deallocate()[SWS_CORE_06548], deallocate_bytes()[SWS_CORE_06550], deallocate_object()[SWS_CORE_06552], and delete_object()[SWS_CORE_06554] are silently ignored without exception.
This guide is based on the specification of ara::core::PolymorphicAllocator from AUTOSAR R25-11 and was generated automatically.
except for the following deviations: 1. The function is noexcept 2. If unsuccessful: nullptr is returned, instead of raising any Exception ≙ [mem.poly.allocator.class]
except for the following deviations: 1. The function is noexcept 2. If unsuccessful: the returned pointer shall be nullptr ≙ [mem.poly.allocator.class]
except for the following deviations: 1. The function is noexcept 2. If unsuccessful: the returned pointer shall be nullptr ≙ [mem.poly.allocator.class]
template <class T> [[nodiscard]] T * allocate_object (std::size_t n=1) noexcept;
except for the following deviations: 1. Function is conditionally noexcept 2. If unsuccessful: errors will be silently ignored ≙ [mem.poly.allocator.class]
except for the following deviations: 1. Function is conditionally noexcept 2. If unsuccessful: nullptr is returned, instead of raising any Exception ≙ [mem.poly.allocator.class]
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: nullptr is returned, instead of raising any Exception
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: e24ff27c5b25ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function allocate of class ara::core::PolymorphicAllocator serves for synchronously requesting uninitialized memory for n objects of type Tp[SWS_CORE_06547]. It is modeled on the functionality of [mem.poly.allocator.class], but deliberately deviates from the C++ standard through the declaration as noexcept and attribute [[nodiscard]][SWS_CORE_06547].
In case of error, allocate does not throw an exception such as std::bad_alloc, but returns a nullptr instead [SWS_CORE_06547]. Because of [[nodiscard]], the caller must explicitly receive the return value and check it for nullptr before using the memory area [SWS_CORE_06547]. Regarding concurrency, the function is classified as exception-safe, but is considered not thread-safe (not thread-safe) [SWS_CORE_06547]. Interpretation: A synchronous call via the same allocator from different threads should therefore require external protection by the caller. Question Q-b00116faadf930fe (open)
The fault-tolerant behavior without exceptions corresponds directly to interface ara::core::MemoryResource::allocate[SWS_CORE_06503], which is likewise defined as noexcept and returns nullptr in case of error. Predefined instances such as NullMemoryResource[SWS_CORE_06563] also use this principle and consistently return nullptr upon allocation calls. At a higher level, this mechanism interacts with containers such as ara::core::Vector[SWS_CORE_01315], whose assignment operators are aligned with such allocation characteristics.
This text was generated automatically. The AUTOSAR specification is authoritative.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: the returned pointer shall be nullptr
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ed713f104c1dProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function allocate_bytes of class ara::core::PolymorphicAllocator reserves raw memory in the amount of nbytes with the specified alignment alignment[SWS_CORE_06549]. The default value for the alignment corresponds to alignof(std::max_align_t)[SWS_CORE_06549]. The function is included via the header ara/core/memory_resource.h and executed synchronously [SWS_CORE_06549].
Error Handling and Semantics
In contrast to the standard behavior according to [mem.poly.allocator.class], the implementation exhibits two deviations [SWS_CORE_06549]:
The function is declared as noexcept and throws no exceptions [SWS_CORE_06549].
If the allocation fails, the function returns nullptr instead of throwing an exception [SWS_CORE_06549].
Due to the attribute [[nodiscard]], the return value must be evaluated by the caller, in particular by checking for nullptr before accessing the memory area [SWS_CORE_06549].
template <class T> [[nodiscard]] T * allocate_object (std::size_t n=1) noexcept;
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: the returned pointer shall be nullptr
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: c04a4d5d02ffProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The template member function allocate_object is part of class ara::core::PolymorphicAllocator and is provided via the header file #include "ara/core/memory_resource.h"[SWS_CORE_06551]. It synchronously allocates memory for n objects of type T, with the parameter n populated with the value 1 by default [SWS_CORE_06551]. The compiler attribute [[nodiscard]] obligates callers not to ignore the returned typed pointer T*.
Error handling
The specification defines two explicit deviations from the standard [mem.poly.allocator.class][SWS_CORE_06551]:
No exceptions: The function is declared as noexcept and specified as exception-safe (exception safe) [SWS_CORE_06551].
Null pointer in case of error: If the memory allocation fails, no exception is thrown; instead, nullptr must be returned [SWS_CORE_06551].
The caller must therefore check the supplied pointer for nullptr immediately before any further use.
Concurrency and Limitations
The operation is specified as not thread-safe (not thread-safe) [SWS_CORE_06551]. When using the same allocator instance concurrently, external synchronization is likely required to avoid data races. In addition, the function reserves pure memory (interpretation: the construction of objects in the reserved memory is the responsibility of downstream mechanisms). Question Q-c41df2caaeb4c503 (open)
This text was generated by an AI and is based on the specification of AUTOSAR R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. Function is conditionally noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: b824902bd6ddProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template function construct of class ara::core::PolymorphicAllocator ([SWS_CORE_06555]) serves to synchronously create an object of type T at the passed memory address p while forwarding the arguments args.... It is defined via the header ara/core/memory_resource.h and essentially follows the requirements from [mem.poly.allocator.class].
An explicit deviation from the C++ standard concerns exception handling: According to [SWS_CORE_06555], the function is conditionally declared as noexcept, depending on whether std::is_nothrow_constructible<T, Args...>::value applies. The specification thus assigns it the attribute conditionally exception safe. Interpretation: Provided that T cannot be constructed exception-free, any constructor exceptions are likely to be propagated unhindered to the caller, as no internal error codes or separate interception mechanisms are defined. Question Q-ad77510f396e59ae (open)
Regarding concurrency and boundary conditions, construct is specified as not thread-safe (not thread-safe) ([SWS_CORE_06555]). In case of parallel accesses to the same allocator instance or the same memory area, external synchronization in the call context is therefore mandatory.
The architectural pattern of a type-dependent noexcept declaration corresponds to the conventions in ara::core, as used among others also for the constructors of ara::core::Result ([SWS_CORE_00725], [SWS_CORE_00726]).
This usage note was generated automatically and relies exclusively on the specification of AUTOSAR Adaptive Release R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 2c2725501203Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function deallocate of class ara::core::PolymorphicAllocator deallocates previously allocated memory for n objects of type Tp starting at address p[SWS_CORE_06548]. The declaration takes place via header ara/core/memory_resource.h[SWS_CORE_06548]. The function generally follows the semantics of the standard C++ allocator according to [mem.poly.allocator.class], but exhibits two specific deviations [SWS_CORE_06548].
Error Handling and Exception Safety
As a key deviation, the operation is declared as noexcept and specified as exception-safe (exception safe) [SWS_CORE_06548]. If freeing the memory fails, occurring errors are silently ignored (silently ignored), so that neither exceptions are thrown nor explicit error codes are returned [SWS_CORE_06548].
Concurrency and Interaction
Regarding the call context, deallocate is classified as not thread-safe (not thread-safe) [SWS_CORE_06548]. In the memory management concept, this function corresponds to method deallocate of the underlying base class ara::core::MemoryResource[SWS_CORE_06504], for which the same deviations regarding noexcept and silent error handling apply.
This usage note was created automatically and is based exclusively on the specification requirements of AUTOSAR Adaptive.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: faf22ebd97f2ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The function deallocate_bytes of class ara::core::PolymorphicAllocator serves to deallocate a previously allocated memory area according to [SWS_CORE_06550]. It is provided via the header ara/core/memory_resource.h and is fundamentally oriented towards the semantics from [mem.poly.allocator.class].
The call is performed synchronously and expects the following parameters according to [SWS_CORE_06550]:
p: Pointer (void*) to the memory area to be deallocated.
nbytes: Size of the memory to be deallocated in bytes (std::size_t).
alignment: Desired alignment (default value alignof(std::max_align_t)).
Regarding error behavior, the implementation exhibits specific deviations from the standard: The function is declared as noexcept and considered exception-safe (exception safe). If the deallocation fails, occurring errors are silently ignored (silently ignored) according to [SWS_CORE_06550]. No exceptions are thrown and no return values are provided.
With respect to concurrency and restrictions, the function is explicitly specified as not thread-safe (not thread-safe) [SWS_CORE_06550]. Concurrent access to the same allocator instance without external synchronization is therefore likely to lead to undefined behavior. Question Q-33c80e3bb50ed64f (open)
This usage note was generated automatically based on release R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. Function is nullptr 2. If unsuccessful: errors will be silently ignored
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d1e41bdb2142ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template function deallocate_object of class ara::core::PolymorphicAllocator serves to deallocate previously reserved object memory [SWS_CORE_06552]. It is based on the corresponding C++ standard use according to [mem.poly.allocator.class], but exhibits specific deviations [SWS_CORE_06552].
Regarding parameters and call context, the following properties apply [SWS_CORE_06552]:
Header: The function is available via #include "ara/core/memory_resource.h"[SWS_CORE_06552].
Return value: The operation yields no return value (void) [SWS_CORE_06552].
Null pointer behavior: As an explicit deviation, it is specified that the function takes effect when passing nullptr or supports null pointers (“Function is nullptr”) [SWS_CORE_06552].
Regarding error handling, the function is declared as noexcept and considered exception-safe (exception safe) [SWS_CORE_06552]. If a deallocation fails, occurring errors are silently ignored (“errors will be silently ignored”), so that no exceptions are propagated to the outside [SWS_CORE_06552].
As a major restriction, deallocate_object is classified as not thread-safe (not thread-safe) [SWS_CORE_06552]. For parallel accesses to the same allocator instance from multiple threads, calls must therefore be protected by external synchronization mechanisms.
This text was created by an AI and is based exclusively on the specifications of Release R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. Function is conditionally noexcept 2. If unsuccessful: errors will be silently ignored
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: c42857d5d063ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function delete_object of class ara::core::PolymorphicAllocator serves according to [SWS_CORE_06554] to destroy and deallocate an object of type T pointed to by the passed pointer p. The function is provided via the header file #include "ara/core/memory_resource.h" and follows the behavior from [mem.poly.allocator.class] with specific deviations.
Regarding call context and semantics, the following properties apply:
Return value and exceptions: The function has no return value (void). It is conditionally exception-safe (conditionally noexcept) with the specification noexcept(std::is_nothrow_destructible<T>::value), meaning it throws no exceptions provided that the destructor of T is declared as non-throwing [SWS_CORE_06554].
Error handling: If the operation fails, occurring errors are silently ignored (errors will be silently ignored) [SWS_CORE_06554]. Interpretation: Callers thus receive neither an error message nor an error code or an exception in the event of an error. Question Q-9393b0f68a055e4b (open)
Thread safety: The operation is specified as not thread-safe (not thread-safe) [SWS_CORE_06554]. When using the same allocator concurrently across multiple threads, synchronization is the responsibility of the caller.
This text was generated by an AI based on specification R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. Function is conditionally noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d8b5334c8292ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The template member function destroy of class ara::core::PolymorphicAllocator ([SWS_CORE_06556]) serves to destroy an object of type T pointed to by the pointer p. The function is declared in header ara/core/memory_resource.h and fundamentally follows the standardized behavior from [mem.poly.allocator.class] ([SWS_CORE_06556]). The method call yields no return value and is executed synchronously in the context of the calling thread. Interpretation: It is likely assumed here that p points to a valid, previously instantiated object.
Question Q-a4faf7034eb683dd (open)
Error Handling and Exception Safety
Regarding error handling, the function is classified as conditionally exception-safe (conditionally exception safe) ([SWS_CORE_06556]). As a specific deviation from the standard requirement [mem.poly.allocator.class], destroy is conditionally declared with noexcept(std::is_nothrow_destructible<T>::value) ([SWS_CORE_06556]). Provided that the destructor of the passed type T throws no exceptions, exception freedom applies to the entire call; otherwise, exceptions resulting from the destructor can escape.
Concurrency and Limitations
Regarding concurrency behavior, destroy is specified as not thread-safe (not thread-safe) ([SWS_CORE_06556]). If multiple threads access the same instance of ara::core::PolymorphicAllocator or the object to be destroyed at the same time, suitable external synchronization mechanisms must be established.
This usage note was generated automatically based on the specification of AUTOSAR Adaptive Release R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. Function is conditionally noexcept 2. If unsuccessful: nullptr is returned, instead of raising any Exception
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d4720bb5fd75ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template member function new_object of class ara::core::PolymorphicAllocator (defined in #include "ara/core/memory_resource.h") synchronously allocates memory and constructs an object of type T with the passed constructor arguments ctor_args[SWS_CORE_06553].
The use is subject to the following stipulations and deviations from the standard [mem.poly.allocator.class][SWS_CORE_06553]:
Call and return value: Upon successful object creation, a typed pointer T* to the new instance is returned. The attribute [[nodiscard]] obligates callers to evaluate the return value.
Error handling: In the event of failure, deviating from [mem.poly.allocator.class], no exception is thrown; instead, nullptr is returned. The caller must therefore imperatively check the resulting pointer for nullptr prior to access.
Exception safety: The function is specified as conditionally exception-safe (conditionally exception safe). It is noexcept if and only if the object creation itself is guaranteed not to throw an exception (noexcept(std::is_nothrow_constructible<T, CtorArgs...>::value)).
Concurrency: The function is declared as not thread-safe (not thread-safe). Interpretation: In case of simultaneous access to the same instance of ara::core::PolymorphicAllocator, the caller is likely responsible for suitable external synchronization. Question Q-3d0ecfe34187c91e (open)
This usage note was automatically generated based on AUTOSAR R25-11.
As per corresponding usage in [mem.poly.allocator.class]
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 90f4d7f53a57ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The method resource is a const member function of class ara::core::PolymorphicAllocator from the header file #include "ara/core/memory_resource.h"[SWS_CORE_06557]. According to the specification reference to [mem.poly.allocator.class], it serves to synchronously retrieve the associated memory resource [SWS_CORE_06557].
Usage and signature
The function signature is MemoryResource * resource () const noexcept;[SWS_CORE_06557]. The call is parameterless and synchronous on an instance of ara::core::PolymorphicAllocator. As a return value, the function returns a pointer of type MemoryResource*[SWS_CORE_06557]. Interpretation: The returned pointer is likely to point directly to the concrete memory resource used by the allocator for memory operations. Question Q-392683a38a4e490b (open)
Error Handling and Concurrency
Exception safety: The function is declared as noexcept and classified as exception safe[SWS_CORE_06557]. It throws no exceptions, and no specific error codes are defined.
Thread safety: The specification explicitly identifies the method as thread-safe[SWS_CORE_06557]. Through the qualification as const, concurrent read access across multiple threads is safe.
Interaction
In module core, resource provides the interface to query the MemoryResource encapsulated by ara::core::PolymorphicAllocator and to address its operations [SWS_CORE_06557].
This usage note was generated by an AI based on the specification AUTOSAR Adaptive R25-11.
As per corresponding usage in [mem.poly.allocator.class] except for the following deviations: 1. The function is noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: c103d893236cProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function select_on_container_copy_construction belongs to the scope of class ara::core::PolymorphicAllocator and is declared via the header file #include "ara/core/memory_resource.h" ([SWS_CORE_06573]). It is called synchronously to create a new instance of PolymorphicAllocator upon copy construction of a container ([SWS_CORE_06573]). The functional behavior follows the requirement [mem.poly.allocator.class] ([SWS_CORE_06573]). Interpretation: The resulting allocator is likely default-constructed and thus falls back to the default memory resource instead of necessarily copying the memory resource of the source container. Question Q-134ed967dc22e133 (open)
Error Handling and Exception Safety
A central deviation from the general C++ specification is that the function in AUTOSAR is explicitly declared as noexcept ([SWS_CORE_06573]). Execution is defined as exception-safe (exception safe) ([SWS_CORE_06573]). Specific error codes, return values for error indication, or messages to DET or DEM are not provided for this interface, as the call is guaranteed to terminate without errors.
Concurrency and Limitations
According to the specification, the function is classified as not thread-safe ([SWS_CORE_06573]). This means that simultaneous calls on the same PolymorphicAllocator instance from multiple threads without external synchronization can lead to data races. Before copying a container in concurrent environments, access to the allocator object must be protected by the user.
This usage note was generated automatically based on the AUTOSAR specification for release R25-11.
gemini-3.8-flash-low· 2026-10-13 · German original