DEENESPTFRRUARHIKOZHNL

struct std::hash< ara::core::StringView >

[SWS_CORE_02189]

template <> struct hash< ara::core::StringView > final {...};

Specialization of std::hash (hashing function for ara::core::StringView)

Header-Datei#include "ara/core/string_view.h"
Forwarding-Header#include "ara/core/core_fwd.h"
Scopenamespace std

User GuideAI-GENERATED

Enables the computation of hash values for StringView objects for use in associative hash containers.
AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 1a39d5491f89 Provenance Open questions (3)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Enables the computation of hash values for StringView objects for use in associative hash containers.

The specialization std::hash<ara::core::StringView> provides the standardized hashing functionality for instances of ara::core::StringView in header <ara/core/string_view.h> [SWS_CORE_02190]. Via call operator operator(), the stateless function object deterministically computes an integer hash value of type size_t from a passed const StringView reference [SWS_CORE_02190]. Due to its strict declaration as noexcept, execution is completely exception-safe and throws no errors at any time. The caller only needs to ensure that the character data referenced by the StringView remains valid in memory during evaluation.

Context

The template specialization std::hash<ara::core::StringView> provides the canonical hashing function for the character string reference ara::core::StringView within the AUTOSAR Adaptive Platform. Defined in header <ara/core/string_view.h> [SWS_CORE_02190], it integrates base type ara::core::StringView directly into the type system of the C++ Standard Library. The primary role of this structure is to act as a standard-compliant function and hashing object. In modern C++ systems and AUTOSAR Adaptive applications built upon them, generic algorithms and associative data structures require standardized hash functors. The specialization is likely to serve primarily as a key hash function for unordered associative containers such as std::unordered_map or std::unordered_set when instances of ara::core::StringView are used as lookup or mapping keys. Question Q-781e3d2bf693742f (open) Because ara::core::StringView represents a non-owning view of contiguous character sequences, std::hash<ara::core::StringView> operates closely with the referenced memory regions without performing its own memory allocations or creating copies of the referenced text.

Lifecycle

According to its declaration, the structure is designed as final specialization template <> struct hash< ara::core::StringView > final. In terms of lifecycle, std::hash<ara::core::StringView> exhibits the characteristics of a functional object. Since the interface specifies no data members, the structure is likely to be completely stateless, allowing instances to be created without explicit resource management. Question Q-17cde1f6c81fd9f1 (open) Instantiation typically occurs implicitly by the calling container or explicitly as a temporary object at the call site. Because no state is maintained, creation is extremely lightweight and requires no dynamic memory allocation. An instance can thus be created, copied, or passed directly as an unnamed rvalue as needed. Destruction of the functor is trivial and requires no release operations. With respect to concurrency and thread safety, the stateless nature permits unrestricted concurrent access: multiple threads can execute the hash function in parallel for different or identical ara::core::StringView instances, as no mutable data structures are modified.

Usage Path

The functional core of the specialization centers on call operator operator() [SWS_CORE_02190]. Typical usage takes place within a two-step flow consisting of instantiation and evaluation. A developer or a standard container passes an instance of ara::core::StringView by const reference to member function operator()(ara::core::StringView const &v) const noexcept [SWS_CORE_02190]. During evaluation, the function reads the character data referenced by the StringView and transforms it into an integer hash value of type size_t [SWS_CORE_02190]. The concrete computation is presumably based on established hash algorithms that strictly yield the same size_t value for two character sequences with identical content, in order to guarantee the integrity of hash tables. Question Q-45be0447105133fd (open) After computation, the resulting value is returned directly to the caller, which uses it, for example, to index a bucket.

Error Scenarios

Due to the specification as noexcept and the classification as exception safe [SWS_CORE_02190], invoking operator() guarantees that exceptions are never thrown or escape the function scope. The interface defines neither specific error codes nor a ara::core::Result return type, as the hash computation can be performed deterministically for every formally valid StringView instance. As an essential precondition, the caller is responsible for ensuring that the passed ara::core::StringView reference points to a valid memory region. While an empty StringView can be hashed without problems and without errors, passing a view with an invalid or already deallocated memory region (dangling pointer) results in undefined behavior during the memory read operation. At the postcondition level, the function guarantees that the passed argument remains unmodified and a deterministic size_t hash value is returned [SWS_CORE_02190].

This class guide was created by an AI curation assistant based on AUTOSAR specification R25-11.

UML class diagram

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

G nstd__hash__ara__core__StringView__122 «struct» hash< ara::core::StringView > + operator()() n_core__StringView___final585 :core::StringView > final nstd__hash__ara__core__StringView__122->n_core__StringView___final585

Operators

operator() function

Invoke the hashing function

size_t operator() (ara::core::StringView const &v) const noexcept;

Method documentation

function operator() [SWS_CORE_02190]

size_t operator() (ara::core::StringView const &v) const noexcept;

Invoke the hashing function

Header-Datei#include "ara/core/string_view.h"
Scopestruct std::hash< ara::core::StringView >
Exception-Sicherheitexception safe

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

Record
AUTOSAR/AP/record/SWS_CORE_02190
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CORE_02190@rel:R25-11#52ddc4c8
Content hash
52ddc4c8
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Core.pdf#nameddest=SWS_CORE_02190
Status: valid/unmigrated Version: rel:R25-11#5fb7ab21 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_02190@rel:R25-11#5fb7ab21
Point-in-Time History:
Recorded Revisions (3):
  • R25-11rel:R25-11#52ddc4c82026-09-30
  • R24-11rel:R24-11#55889b1d2026-10-14
  • R25-11rel:R25-11#5fb7ab212026-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