ClikaRT::Result< void >
class
Header: ClikaRT/common/result.h
Outcome of a fallible operation that yields no value on success (e.g. registering a route, writing a file). Check ok(), or call value_or_throw() to raise ClikaRT::Error on failure in your own TU. [[nodiscard]]: a statement-position effect call that ignores its result swallows the failure; the compiler warns; consume it (CLIKART_CHECK, unwrap, a named read) or discard deliberately with a (void) cast.
Member functions
Result()
Result()
Success.
Declared in ClikaRT/common/result.h, line 303
Result(Status, string)
Result(Status status, std::string message = std::string())
Failure (a Status other than Ok, with an optional message). A failure with the coarse status and a readable message (an Ok status is coerced to a failure; void success is the default ctor).
Declared in ClikaRT/common/result.h, line 307
Result(Status, string, string)
Result(
Status status,
std::string message,
std::string code_name
)
Failure carrying the fine-grained status NAME the failure originated with (see code_name()).
Declared in ClikaRT/common/result.h, line 312
ok()
bool ok() const noexcept
True on success.
Declared in ClikaRT/common/result.h, line 318
operator bool()
explicit operator bool() const noexcept
Tests OKNESS: if (auto r = ...); the void form has no payload to confuse it with.
Declared in ClikaRT/common/result.h, line 320
status()
Status status() const noexcept
the coarse status; Ok on success
Declared in ClikaRT/common/result.h, line 321
message()
const std::string& message() const noexcept
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()).
Declared in ClikaRT/common/result.h, line 327
code_name()
const std::string& code_name() const noexcept
The stable NAME of the fine-grained status the failure originated with (e.g. "TIMED_OUT"); empty on success and for a failure that did not originate inside the runtime. Machine-readable in EVERY build; it survives release obfuscation even when message() is an opaque code; status() remains the coarse switch.
Declared in ClikaRT/common/result.h, line 333
value_or_throw()
void value_or_throw() const
No-op on success; raises on failure (throws ClikaRT::Error, or aborts with a diagnostic when exceptions are disabled).
Declared in ClikaRT/common/result.h, line 337
operator=()
Move-assign: transfers the payload or the failure state.
Declared in ClikaRT/common/result.h, line 208
~Result()
~Result()
Destroys the held value, when one is present.
Declared in ClikaRT/common/result.h, line 222
value()
void& value() noexcept
The value. Precondition: ok().
Declared in ClikaRT/common/result.h, line 246
operator typename std::conditional< std::is_same< typename std::remove_cv< void >::type, bool >::value, detail::NoImplicitBoolExtraction, void >::type()
operator typename std::conditional< std::is_same< typename std::remove_cv< void >::type, bool >::value, detail::NoImplicitBoolExtraction, void >::type(
) &&
Implicit extraction from a TEMPORARY result (T x = fn(...);, g(fn(...))), moving the value out or raising exactly as value_or_throw(), so value-shaped call sites keep compiling under the Result-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 is read through ok()/value()/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.
Declared in ClikaRT/common/result.h, line 273