---
title: "ClikaRT::Result"
sidebar_label: "Result"
description: "Holds either a success value of type T or a (Status, message) failure. Move-only. Check ok() before reading value(), or use value_or_throw()."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/common/result.h`  
**Template:** `template <``typename T``>`

Holds either a success value of type T or a ([Status](../index.md#Status), message) failure. Move-only. Check [ok()](./Result.md#ok) before reading [value()](./Result.md#value), or use [value\_or\_throw()](./Result.md#value_or_throw). \[\[nodiscard\]\]: a call that returns a [`Result`](./Result.md) and discards it swallows the failure it may carry; the compiler warns at such a site; consume it ([`unwrap`](../index.md#unwrap), [`CLIKART_CHECK`](../index.md#CLIKART_CHECK), a named read) or discard deliberately with a `(void)` cast.

## Member functions

### Result(T) {#Result}

<div class="api-signature">

**`Result`**(`T` `value`)

</div>

Success.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 207

</div>

### Result(Status, string) {#Result-2}

<div class="api-signature">

**`Result`**([`Status`](../index.md#Status) `status`, `std::string` `message` `=` `std::string()`)

</div>

Failure (a [Status](../index.md#Status) other than Ok, with an optional message).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 212

</div>

### Result(Status, string, string) {#Result-3}

<div class="api-signature">

**`Result`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Status`](../index.md#Status) `status`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string` `message`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string` `code_name`<br />
)

</div>

Failure carrying the fine-grained status NAME the failure originated with (see [`code_name()`](./Result.md#code_name)).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 218

</div>

### Result(Result) {#Result-4}

<div class="api-signature">

**`Result`**(`Result&&` `other`)

</div>

Move: transfers the payload or the failure state.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 225

</div>

### operator=(Result) {#operator-assign}

<div class="api-signature">

[`Result`](./Result.md)`&` **`operator=`**([`Result`](./Result.md)`&&` `other`)

</div>

Move-assign: transfers the payload or the failure state.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 231

</div>

### Result(Result) {#Result-5}

<div class="api-signature">

**`Result`**(`const Result&`) `=delete`

</div>

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 242

</div>

### operator=(Result) {#operator-assign-2}

<div class="api-signature">

[`Result`](./Result.md)`&` **`operator=`**(`const` [`Result`](./Result.md)`&`) `=delete`

</div>

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 243

</div>

### \~Result() {#Result-6}

<div class="api-signature">

**`~Result`**()

</div>

Destroys the held value, when one is present.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 245

</div>

### ok() {#ok}

<div class="api-signature">

`bool` **`ok`**() `const noexcept`

</div>

True on success.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 248

</div>

### operator bool() {#operator-bool}

<div class="api-signature">

`explicit` **`operator bool`**() `const noexcept`

</div>

Tests OKNESS: `if (auto r = ...)`. NOTE: on a [`Result`](./Result.md)`<bool>` this is NOT the payload; read [`value()`](./Result.md#value) for the answer (bool payloads are excluded from implicit extraction so this stays the ONLY bool conversion).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 253

</div>

### status() {#status}

<div class="api-signature">

[`Status`](../index.md#Status) **`status`**() `const noexcept`

</div>

the coarse status; Ok on success

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 254

</div>

### message() {#message}

<div class="api-signature">

`const std::string&` **`message`**() `const noexcept`

</div>

Diagnostic message; empty on success. A failure you can act on reads as plain text in every build and names the value it refuses; a message of the form `E<digits>` is an internal fault code, build-specific and never an identifier to record or compare (report it verbatim with the runtime version, and branch on [`code_name()`](./Result.md#code_name)).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 260

</div>

### code\_name() {#code_name}

<div class="api-signature">

`const std::string&` **`code_name`**() `const noexcept`

</div>

The stable NAME the failure originated with: a runtime status name (e.g. "TIMED\_OUT") or the name a consumer's model minted (an [`Error`](./Error.md) raised inside a phase body crosses the engine and comes back with its own [`code_name`](./Result.md#code_name) unchanged); empty on success and for a failure that carries no name. Machine-readable in EVERY build; it survives release obfuscation even when [`message()`](./Result.md#message) is an opaque code; [`status()`](./Result.md#status) remains the coarse switch.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 268

</div>

### value() {#value}

<div class="api-signature">

`T&` **`value`**() `noexcept`

</div>

The value. Precondition: [ok()](./Result.md#ok).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 271

</div>

### value() {#value-2}

<div class="api-signature">

`const T&` **`value`**() `const noexcept`

</div>

const access; same precondition

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 272

</div>

### value\_or\_throw() {#value_or_throw}

<div class="api-signature">

`T` **`value_or_throw`**()

</div>

Move the value out, or raise on failure (throws [ClikaRT::Error](./Error.md), or aborts with a diagnostic when exceptions are disabled).

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 276

</div>

### operator typename std::conditional\< std::is\_same\< typename std::remove\_cv\< T \>::type, bool \>::value, detail::NoImplicitBoolExtraction, T \>::type() {#operator-typename-std-conditional-std-is-same-typename-std-remove-cv-t-type-bool-value-detail-noimplicitboolextraction-t-type}

<div class="api-signature">

**`operator typename std::conditional< std::is_same< typename std::remove_cv< T >::type, bool >::value, detail::NoImplicitBoolExtraction, T >::type`**(<br />
) `&&`

</div>

Implicit extraction from a TEMPORARY result (`T x = fn(...);`, `g(fn(...))`), moving the value out or raising exactly as [`value_or_throw()`](./Result.md#value_or_throw), so value-shaped call sites keep compiling under the [`Result`](./Result.md)-returning surface and adopt explicit handling at their own pace. A plain (non-template) conversion so overload resolution and standard-conversion tails match the value-returning surface exactly (`long n = size_fn();`, `g(int)` vs `g(long)` picks as it would on a bare `int`). Deliberately rvalue-only (a named [`Result`](./Result.md) is read through [`ok()`](./Result.md#ok)/[`value()`](./Result.md#value)/[`unwrap`](../index.md#unwrap)), and `bool` payloads are excluded (the conversion target degrades to an unusable detail tag): `operator bool` means OKNESS everywhere, never the payload. Note a bool DESTINATION fed by a non-bool payload still follows the payload's own conversion (`bool any = count_fn();` and `if (count_fn())` test \!= 0, raising on failure, as the value surface would); the okness test is the named form, `if (auto r = fn())`, where this rvalue-qualified conversion is not viable.

<div class="api-declared">

Declared in `ClikaRT/common/result.h`, line 298

</div>
