template <typename T>

class StatusOr

Defined at line 71 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

Public Methods

void StatusOr<T> (const StatusOr<T> & )

StatusOr

<T

> will be copy constructible/assignable if T is copy

constructible.

Defined at line 90 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

StatusOr<T> & operator= (const StatusOr<T> & )

Defined at line 91 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> (StatusOr<T> && )

StatusOr

<T

> will be move constructible/assignable if T is move

constructible.

Defined at line 95 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

StatusOr<T> & operator= (StatusOr<T> && )

Defined at line 96 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

bool ok ()

Returns this->status().ok()

Defined at line 148 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

bool operator bool ()

Defined at line 149 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T & ValueOr (const T & other)

Defined at line 151 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T ConsumeValueOr (T other)

Defined at line 158 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T ConsumeValueOrDie ()

Defined at line 194 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> ()

Constructs a new StatusOr with Status::UNKNOWN status. This is marked

'explicit' to try to catch cases like 'return {};', where people think

StatusOr

<std

::vector

<int

>> will be initialized with an empty vector,

instead of a Status::UNKNOWN status.

Defined at line 236 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

template <typename U>
void StatusOr<T> (const StatusOr<U> & other)

Conversion copy/move constructor, T must be convertible from U.

TODO(b/62186717): These should not participate in overload resolution if U

is not convertible to T.

Defined at line 263 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

template <typename U>
void StatusOr<T> (StatusOr<U> && other)

Defined at line 279 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

template <typename U>
StatusOr<T> & operator= (const StatusOr<U> & other)

Conversion copy/move assignment operator, T must be convertible from U.

Defined at line 268 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

template <typename U>
StatusOr<T> & operator= (StatusOr<U> && other)

Defined at line 284 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> (const T & value)

Constructs a new StatusOr with the given value. After calling this

constructor, calls to ValueOrDie() will succeed, and calls to status() will

return OK.

NOTE: Not explicit - we want to use StatusOr

<T

> as a return type

so it is convenient and sensible to be able to do 'return T()'

when the return type is StatusOr

<T

>.

REQUIRES: T is copy constructible.

Defined at line 239 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> (const Status & status)

Constructs a new StatusOr with the given non-ok status. After calling

this constructor, calls to ValueOrDie() will CHECK-fail.

NOTE: Not explicit - we want to use StatusOr

<T

> as a return

value, so it is convenient and sensible to be able to do 'return

Status()' when the return type is StatusOr

<T

>.

REQUIRES: !status.ok(). This requirement is DCHECKed.

In optimized builds, passing Status::OkStatus() here will have the effect

of passing tensorflow::error::INTERNAL as a fallback.

Defined at line 242 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

StatusOr<T> & operator= (const Status & status)

Defined at line 245 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> (T && value)

Similar to the `const T

&

` overload.

REQUIRES: T is move constructible.

Defined at line 251 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void StatusOr<T> (Status && status)

RValue versions of the operations declared above.

Defined at line 254 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

StatusOr<T> & operator= (Status && status)

Defined at line 257 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const Status & status ()

Returns a reference to our status. If this contains a T, then

returns Status::OkStatus().

Defined at line 295 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

Status status ()

Defined at line 299 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T & ValueOrDie ()

Returns a reference to our current value, or CHECK-fails if !this->ok().

Note: for value types that are cheap to copy, prefer simple code:

T value = statusor.ValueOrDie();

Otherwise, if the value type is expensive to copy, but can be left

in the StatusOr, simply assign to a reference:

T

&

value = statusor.ValueOrDie(); // or `const T

&

`

Otherwise, if the value type supports an efficient move, it can be

used as follows:

T value = std::move(statusor).ValueOrDie();

The std::move on statusor instead of on the whole expression enables

warnings about possible uses of the statusor object after the move.

C++ style guide waiver for ref-qualified overloads granted in cl/143176389

See go/ref-qualifiers for more details on such overloads.

Defined at line 328 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T & ValueOrDie ()

Defined at line 334 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T && ValueOrDie ()

Defined at line 340 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T && ValueOrDie ()

Defined at line 346 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T & value ()

StatusOr

<T

>::value()

absl::StatusOr compatible versions of ValueOrDie and value.

Defined at line 304 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T & value ()

Defined at line 310 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T && value ()

Defined at line 316 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T && value ()

Defined at line 322 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T & operator* ()

Returns a reference to the current value.

REQUIRES: this->ok() == true, otherwise the behavior is undefined.

Use this->ok() or `operator bool()` to verify that there is a current

value. Alternatively, see value() for a similar API that guarantees

CHECK-failing if there is no current value.

Defined at line 364 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T & operator* ()

Defined at line 370 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T && operator* ()

Defined at line 376 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T && operator* ()

Defined at line 382 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

const T * operator-> ()

Returns a pointer to the current value.

REQUIRES: this->ok() == true, otherwise the behavior is undefined.

Use this->ok() or `operator bool()` to verify that there is a current

value.

Defined at line 352 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

T * operator-> ()

Defined at line 358 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

void IgnoreError ()

Ignores any errors. This method does nothing except potentially suppress

complaints from any tools that are checking that errors are not dropped on

the floor.

Defined at line 388 of file ../../third_party/cobalt/src/public/lib/statusor/statusor.h

Friends

template <typename U>
class StatusOr