template <typename T, typename E = ErrorCode> class Result final {...};
This class is a type that contains either a value or an error. The implementation shall flag the condition E != ara::core::ErrorCode as a compile error.
Encapsulates either a success value or an error value for synchronous, exception-free result transmission.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 33e53dcae988ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Encapsulates either a success value or an error value for synchronous, exception-free result transmission.
The class represents a type-safe container that holds either a payload value or an error code to transmit computation results synchronously and without C++ exceptions [SWS_CORE_00751]. Callers create instances via dedicated constructors or factory functions and subsequently evaluate the result conditionally via check and access functions such as value or error access. As an essential constraint, the underlying error type must strictly correspond to the standard error code, as differing type assignments are rejected at compile time. In addition, functions for triggering exceptions require a compiler environment with C++ exceptions enabled [SWS_CORE_00766].
Context
The class ara::core::Result is the central construct of the AUTOSAR Adaptive Platform for the synchronous, typed return of operation results without the mandatory use of C++ exceptions. It represents a tagged union that contains either a payload value of type value_type (T) or an error of type error_type (E) at any point in time [SWS_CORE_00711][SWS_CORE_00712]. By default, ara::core::ErrorCode acts as the type for E; deviating error definitions are prevented by implementations already at compile time through a compiler error.
In the application architecture, ara::core::Result mediates between called services and consumers. Services instantiate the object to return the status, while consumers trigger further processing via state tests such as [SWS_CORE_00751] or functional chaining such as [SWS_CORE_00768]. Furthermore, the state can be converted into ara::core::Optional via [SWS_CORE_00770] (Ok) and [SWS_CORE_00772] (Err).
The destructor releases the active element and is considered trivially destructible if both T and E are trivially destructible [SWS_CORE_00727]. With regard to concurrency, purely reading accesses are thread-safe, whereas modifying operations such as EmplaceValue, EmplaceError, move assignments, or Swap are not thread-safe and require external synchronization.
State check: The caller checks whether a value is present using HasValue()[SWS_CORE_00751] or the explicit conversion operator operator bool()[SWS_CORE_00752]. The latter is disabled if T itself is of type bool.
Functional transformation: Alternatively, Bind()[SWS_CORE_00768] permits monadic further processing: The passed callable is executed only if a payload value is contained; an existing error is propagated unchanged into the new Result instance. Fallbacks can be mapped with Resolve()[SWS_CORE_00767].
If exception handling is desired, ValueOrThrow() ([SWS_CORE_00766], [SWS_CORE_00769], [SWS_CORE_00778]) throws the C++ exception associated with the error in the event of an error. If C++ exceptions are disabled in the compiler, ValueOrThrow() is removed from overload resolution [SWS_CORE_00766]; likewise, the non-const lvalue overload of operator* is disabled in this case [SWS_CORE_00774].
This guide was generated by an AI curation assistant based on the specification requirements of AUTOSAR Adaptive R25-11.
Return the contained value or the given default value. If *this contains a value, it is returned. Otherwise, the specified default value is returned, static_cast’d to T
Return the contained error or the given default error. If *this contains an error, it is returned. Otherwise, the specified default error is returned, static_cast’d to E
Apply the given Callable to the value of this instance, and return a new ara::core:: Result with the result of the call.
The Callable is expected to be compatible to one of these two interfaces: • Result<XXX, E> f(const T&); • <ARTechTerm{XXX f(const T&);}> • <ARNewline{}> • <ARNewline{}> • <ARTechTerm{Callable}> • Result<XXX> or a XXX directly, where XXX can be any type that is suitable for use by ara::core::Result.
The return type of this function is decltype(f(Value())) for a template argument F that returns a ara::core::Result type, and it is Result<decltype(f(Value())), E> for a template argument F that does not return a ara::core::Result type.
If this instance does not contain a value, a new Result<XXX, E> is still created and returned, with the original error contents of this instance being copied into the new instance.}>}
Return the contained error or the given default error. If *this contains an error, it is returned. Otherwise, the specified default error is returned, static_cast’d to E
Return the contained error or the given default error. If *this contains an error, it is std:: move’d into the return value. Otherwise, the specified default error is returned, static_cast’d to E
Build a new ara::core::Result from an error that is constructed in-place from the given arguments. This function shall not participate in overload resolution unless: • std::is_constructible<E, Args&&...>::value == true and • the first type of the expanded parameter pack is not E and • the first type of the expanded parameter pack is not a specialization of ara::core::Result
Build a new ara::core::Result from a value that is constructed in-place from the given arguments. This function shall not participate in overload resolution unless: • std::is_constructible<T, Args&&...>::value == true and • the first type of the expanded parameter pack is not T and • the first type of the expanded parameter pack is not a specialization of ara::core::Result
Return the contained value or return the result of a function call.
If *this contains a value, it is returned. Otherwise, the specified callable is invoked and its return value which is to be compatible to type T is returned from this function.
The Callable is expected to be compatible to this interface: T f(const E&);
Return the contained value or the given default value. If *this contains a value, it is returned. Otherwise, the specified default value is returned, static_cast’d to T
Return the contained value or the given default value. If *this contains a value, it is returned. Otherwise, the specified default value is returned, static_cast’d to T
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 38c9cb36d652ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Usage and Invocation
The synchronous member function ValueOrThrow of class ara::core::Result ([SWS_CORE_00766]) is included via the header ara/core/result.h ([SWS_CORE_00766]). It is called without parameters on a const lvalue instance and returns a const reference (const T &) to the value stored in the object ([SWS_CORE_00766]).
Error Handling and Exception Behavior
If the Result instance contains no value, but an error state, the function throws the C++ exception associated with the error ([SWS_CORE_00766]). The specification classifies the function as not exception-safe (not exception safe) ([SWS_CORE_00766]); Interpretation: This classification is likely due to the fact that an exception is intended to be thrown in the event of an error. Question Q-0f4ebba70af6e48c (open)
Concurrency and Limitations
The operation is specified as thread-safe (thread-safe) ([SWS_CORE_00766]). An essential constraint is: If C++ exceptions are disabled in the compiler toolchain, this function does not participate in overload resolution (overload resolution) ([SWS_CORE_00766]).
Interaction in the Result Framework
The function complements related overloads and specializations within ara::core::Result:
For mutable lvalues, the variant returning T & exists ([SWS_CORE_00778]).
For rvalue instances, the move overload returning T && is available ([SWS_CORE_00769]).
For void results, the specialization ara::core::Result<void, E> without return value exists ([SWS_CORE_00866]).
For reference types ara::core::Result<T &, E>, corresponding const and non-const reference overloads are available ([SWS_CORE_00938], [SWS_CORE_00949]).
This usage note was generated automatically and serves as guidance. Only the specifications of AUTOSAR are binding.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: bf00696cade5Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function ValueOrThrow() && is provided via header #include "ara/core/result.h" and serves for synchronous access to the value encapsulated in a ara::core::Result instance ([SWS_CORE_00769]). Due to the rvalue qualification (&&), the function is called on rvalue objects and returns an rvalue reference (T &&) to the contained value [SWS_CORE_00769].
Error Handling and Boundary Conditions
If the Result object holds an error value, the method throws the exception type associated with the error ([SWS_CORE_00769]). The specification classifies the execution as not exception safe (not exception safe), but explicitly defines it as thread-safe (thread-safe) [SWS_CORE_00769]. A mandatory requirement concerns the toolchain: If C++ exceptions are disabled in the compiler, the function shall under no circumstances participate in overload resolution [SWS_CORE_00769].
Interaction in the Overload Set
The method [SWS_CORE_00769] is part of a coordinated set of overloads for ValueOrThrow within ara::core::Result:
For lvalues, the const overload [SWS_CORE_00766] (return: const T &) and the non-const variant [SWS_CORE_00778] (return: T &) are available.
For void results, the specialization ara::core::Result<void, E> offers the function [SWS_CORE_00866] without a return value.
For reference types, ara::core::Result<T &, E> covers corresponding reference returns with [SWS_CORE_00938] (const) and [SWS_CORE_00949] (non-const).
This usage note was generated automatically based on the AUTOSAR Adaptive R25-11 specification.
Return a reference to the contained value or throw an exception.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ddfa99362222ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function ValueOrThrow[SWS_CORE_00778] of class ara::core::Result (header #include "ara/core/result.h") enables synchronous access to the contained value. Since the function signature is provided with the ref-qualifier &, it can be called exclusively on non-const lvalue instances. It expects no input parameters and returns a modifiable reference (T&) to the encapsulated value.
Error Handling and Boundary Conditions
If the object contains an error rather than a value, ValueOrThrow synchronously throws the exception associated with the error (noexcept(false)) [SWS_CORE_00778]. The function is specified as not exception safe[SWS_CORE_00778]; interpretation: this likely means that when an error occurs, control flow is interrupted by throwing the exception and no further recovery or rollback guarantees are provided. Question Q-11aed84264f3411f (open) If C++ exceptions are disabled in the compiler toolchain, the function mandatorily does not participate in overload resolution [SWS_CORE_00778]. Regarding concurrency, execution is designated as thread-safe [SWS_CORE_00778].
Interaction
The function is part of an overload set for value access in ara::core::Result:
For const instances, the overload returning const T& is provided [SWS_CORE_00766].
For rvalue objects, a variant with move semantics exists that returns T&&[SWS_CORE_00769].
For specializations with reference types (Result<T&, E>), corresponding overloads for modifiable references [SWS_CORE_00949] as well as const references [SWS_CORE_00938] are available.
For instances without a value (Result<void, E>), the method merely checks for the presence of an error and throws the exception if applicable [SWS_CORE_00866].
This text was generated by an AI system and is based on the AUTOSAR Adaptive Release R25-11 specification.
gemini-3.8-flash-low· 2026-10-13 · German original