Serves as a function object for comparing two key-value pairs of a map by their keys.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: a8fa08ca7764ProvenanceOpen questions (3)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as a function object for comparing two key-value pairs of a map by their keys.
The helper class ara::core::Map::value_compare serves as a function object for relationally comparing two value pairs of a map based on their keys using an internally encapsulated comparison predicate [SWS_CORE_01421]. Instantiation is performed in a protected manner primarily by the enclosing map structure, while callers carry out the evaluation via the call operator operator()[SWS_CORE_01423]. Because the operations are not exception-safe according to the specification, calling code must account for possible exceptions from the underlying predicate.
Context
The helper class ara::core::Map::value_compare provides a function object in module core of the AUTOSAR Adaptive Platform, with the help of which two complete key-value elements (value_type) of an associative map can be compared. According to the specification, the class follows the established behavior of the C++ standard library for [map]. Its central task is to make the predicate of type Compare defined for ordering keys applicable to entire value pairs. For this purpose, the class encapsulates an internal instance of this predicate in the protected member variable comp[SWS_CORE_01421]. In this way, value_compare interacts directly with the enclosing data structure ara::core::Map and ensures externally that sorting or search algorithms can consistently compare value pairs by their keys.
Lifecycle
The instantiation of value_compare is subject to strict access restrictions: constructor value_compare(Compare c) is provided with visibility protected[SWS_CORE_01422]. Interpretation: Due to this protected visibility, the creation of new instances is likely primarily reserved for the enclosing class ara::core::Map itself, while ordinary callers obtain ready-to-use function objects from the map. Question Q-f188cfa9cf627a11 (open) Upon construction, the object takes the comparison predicate and stores it in the protected variable comp[SWS_CORE_01421]. A lifecycle with complex state transitions does not exist; after its creation, the instance remains in an immutable execution state. For concurrent operation, this means that parallel read accesses via the call operator are non-critical as long as the encapsulated predicate Compare operates statelessly or thread-safely.
Usage Path
The regular usage path focuses on the repeated evaluation of value pairs via the function call operator operator()[SWS_CORE_01423]. This operator is declared as a const method and accepts two references to constant elements of type value_type. Interpretation: During execution, operator() accesses the key components of the two passed value pairs and passes them to the predicate [SWS_CORE_01421] stored in comp in order to return the relational result as a boolean value. Question Q-207114486c204301 (open) The following diagram illustrates this standardized sequence:
Sequence diagram: Sequence of the value comparison via operator() and the encapsulated predicate comp. Sources: [SWS_CORE_01421], [SWS_CORE_01423]
This path is typically used in algorithms that need to check or traverse elements of a map based on their sort order without requiring the user to manually dereference the keys from the value pairs.
Error Scenarios
Regarding robustness and exception handling, it should be noted that neither the constructor [SWS_CORE_01422] nor the call operator operator()[SWS_CORE_01423] is specified as exception-safe; both are explicitly classified as “not exception safe”. Interpretation: In practice, this means that the class does not encapsulate its own exception handling mechanisms and exceptions thrown during the copying or execution of the user-defined predicate Compare are propagated directly to the caller. Question Q-427fd0afbba7bf9e (open) The specification does not define specific error codes for this helper class. Therefore, essential prerequisites for error-free operation are that the passed predicate Compare can be instantiated and executed without error, and that the references to value_type passed to operator() are valid.
This guide is based on the specification of the AUTOSAR Adaptive Platform for Release R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 167c47c6c4cdProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The constructor [SWS_CORE_01422] of the nested helper class ara::core::Map::value_compare initializes a comparison object for value elements using a passed predicate Compare c. According to the specification, the visibility is declared as protected; users therefore do not construct instances directly in regular application code, but typically obtain them via the member function ara::core::Map::value_comp()[SWS_CORE_01489].
Interaction and Semantics
The interaction within the class comprises the following aspects:
Evaluation: The stored predicate then serves for evaluation by operator()[SWS_CORE_01423] to compare two elements of type value_type based on their keys.
Header inclusion: The declaration is provided via header file #include "ara/core/map.h".
Error Handling and Restrictions
The specification explicitly classifies the function as not exception safe[SWS_CORE_01422]. Specific error codes, DET notifications, or DEM notifications are not defined for this constructor. In addition, callers must not perform direct instantiation outside derived contexts due to the protected visibility (protected).
This text was created by an AI and is based solely on specification data from AUTOSAR R25-11.
gemini-3.8-flash-low· 2026-10-13 · German original