Constructs a new StatusOr<T> from a value convertible to Status.

Synopsis

Declared in <absl/status/statusor.h>

template<typename U = absl::Status>
requires internal_statusor::IsConstructionFromStatusValid<
                                 false, T, U>::value
StatusOr(U&& v);

Description

Constructs a new absl::StatusOr<T> with a non‐ok status. After calling this constructor, this‐>ok() will be false and calls to value() will crash, or produce an exception if exceptions are enabled.

The constructor also takes any type U that is convertible to absl::Status. This constructor is explicit if an only if U is not of type absl::Status and the conversion from U to Status is explicit.

REQUIRES: !Status(std::forward<U>(v)).ok(). This requirement is DCHECKed. In optimized builds, passing absl::OkStatus() here will have the effect of passing absl::StatusCode::kInternal as a fallback.

Parameters

Name

Description

v

The status (or value convertible to a status) to store.

Created with MrDocs