template <typename T>

class StatusOr

Defined at line 192 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

TODO(b/176172494): ABSL_MUST_USE_RESULT should expand to the more strict

[[nodiscard]]. For now, just use [[nodiscard]] directly when it is available.

Public Methods

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

`StatusOr

<T

>` is copy constructible if `T` is copy constructible.

Defined at line 228 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

`StatusOr

<T

>` is copy assignable if `T` is copy constructible and copy

assignable.

Defined at line 231 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

`StatusOr

<T

>` is move constructible if `T` is move constructible.

Defined at line 234 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

`StatusOr

<T

>` is moveAssignable if `T` is move constructible and move

assignable.

Defined at line 237 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    false, T, U, false, const U&>::value,
                                                int> = 0>
void StatusOr<T> (const StatusOr<U> & other)

Constructs a new `absl::StatusOr

<T

>` from an `absl::StatusOr

<U

>`, when `T`

is constructible from `U`. To avoid ambiguity, these constructors are

disabled if `T` is also constructible from `StatusOr

<U

>.`. This constructor

is explicit if and only if the corresponding construction of `T` from `U`

is explicit. (This constructor inherits its explicitness from the

underlying constructor.)

Defined at line 251 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    false, T, U, true, const U&>::value,
                                                int> = 0>
void StatusOr<T> (const StatusOr<U> & other)

Defined at line 257 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    true, T, U, false, const U&>::value,
                                                int> = 0>
void StatusOr<T> (const StatusOr<U> & other)

Defined at line 263 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    true, T, U, true, const U&>::value,
                                                int> = 0>
void StatusOr<T> (const StatusOr<U> & other)

Defined at line 269 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    false, T, U, false, U&&>::value,
                                                int> = 0>
void StatusOr<T> (StatusOr<U> && other)

Defined at line 276 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    false, T, U, true, U&&>::value,
                                                int> = 0>
void StatusOr<T> (StatusOr<U> && other)

Defined at line 282 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    true, T, U, false, U&&>::value,
                                                int> = 0>
void StatusOr<T> (StatusOr<U> && other)

Defined at line 288 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<
                                                internal_statusor::IsConstructionFromStatusOrValid<
                                                    true, T, U, true, U&&>::value,
                                                int> = 0>
void StatusOr<T> (StatusOr<U> && other)

Defined at line 294 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
                                                      T, const U&, false>::value,
                                                  int> = 0>
StatusOr<T> & operator= (const StatusOr<U> & other)

Creates an `absl::StatusOr

<T

>` through assignment from an

`absl::StatusOr

<U

>` when:

* Both `absl::StatusOr

<T

>` and `absl::StatusOr

<U

>` are OK by assigning

`U` to `T` directly.

* `absl::StatusOr

<T

>` is OK and `absl::StatusOr

<U

>` contains an error

code by destroying `absl::StatusOr

<T

>`'s value and assigning from

`absl::StatusOr

<U

>'

* `absl::StatusOr

<T

>` contains an error code and `absl::StatusOr

<U

>` is

OK by directly initializing `T` from `U`.

* Both `absl::StatusOr

<T

>` and `absl::StatusOr

<U

>` contain an error

code by assigning the `Status` in `absl::StatusOr

<U

>` to

`absl::StatusOr

<T

>`

These overloads only apply if `absl::StatusOr

<T

>` is constructible and

assignable from `absl::StatusOr

<U

>` and `StatusOr

<T

>` cannot be directly

assigned from `StatusOr

<U

>`.

Defined at line 320 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
                                                      T, const U&, true>::value,
                                                  int> = 0>
StatusOr<T> & operator= (const StatusOr<U> & other)

Defined at line 328 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
                                                      T, U&&, false>::value,
                                                  int> = 0>
StatusOr<T> & operator= (StatusOr<U> && other)

Defined at line 336 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
                                                      T, U&&, true>::value,
                                                  int> = 0>
StatusOr<T> & operator= (StatusOr<U> && other)

Defined at line 344 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = absl::Status, absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
                                                      false, T, U>::value,
                                                  int> = 0>
void StatusOr<T> (U && v)

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.

Defined at line 364 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = absl::Status, absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
                                                      true, T, U>::value,
                                                  int> = 0>
void StatusOr<T> (U && v)

Defined at line 370 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = absl::Status, absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
                                                      false, T, U>::value,
                                                  int> = 0>
StatusOr<T> & operator= (U && v)

Defined at line 375 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, typename std::enable_if<
                                    internal_statusor::IsAssignmentValid<T, U, false>::value,
                                    int>::type = 0>
StatusOr<T> & operator= (U && v)

If `*this` contains a `T` value before the call, the contained value is

assigned from `std::forward

<U

>(v)`; Otherwise, it is directly-initialized

from `std::forward

<U

>(v)`.

This function does not participate in overload unless:

1. `std::is_constructible_v

<T

, U>` is true,

2. `std::is_assignable_v

<T

&

, U>` is true.

3. `std::is_same_v

<StatusOr

<T

>, std::remove_cvref_t

<U

>>` is false.

4. Assigning `U` to `T` is not ambiguous:

If `U` is `StatusOr

<V

>` and `T` is constructible and assignable from

both `StatusOr

<V

>` and `V`, the assignment is considered bug-prone and

ambiguous thus will fail to compile. For example:

StatusOr

<bool

> s1 = true; // s1.ok()

&

&

*s1 == true

StatusOr

<bool

> s2 = false; // s2.ok()

&

&

*s2 == false

s1 = s2; // ambiguous, `s1 = *s2` or `s1 = bool(s2)`?

Defined at line 400 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, typename std::enable_if<
                                    internal_statusor::IsAssignmentValid<T, U, true>::value,
                                    int>::type = 0>
StatusOr<T> & operator= (U && v)

Defined at line 408 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, absl::enable_if_t<internal_statusor::IsConstructionValid<
                                                      false, T, U, false>::value,
                                                  int> = 0>
void StatusOr<T> (U && u)

Constructs the inner value `T` in-place using the provided args, using the

`T(U)` (direct-initialization) constructor. This constructor is only valid

if `T` can be constructed from a `U`. Can accept move or copy constructors.

This constructor is explicit if `U` is not convertible to `T`. To avoid

ambiguity, this constructor is disabled if `U` is a `StatusOr

<J

>`, where

`J` is convertible to `T`.

Defined at line 432 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, absl::enable_if_t<internal_statusor::IsConstructionValid<
                                                      false, T, U, true>::value,
                                                  int> = 0>
void StatusOr<T> (U && u)

Defined at line 438 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, absl::enable_if_t<internal_statusor::IsConstructionValid<
                                                      true, T, U, false>::value,
                                                  int> = 0>
void StatusOr<T> (U && u)

Defined at line 445 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U = T, absl::enable_if_t<
                                    internal_statusor::IsConstructionValid<true, T, U, true>::value,
                                    int> = 0>
void StatusOr<T> (U && u)

Defined at line 451 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

bool ok ()

StatusOr

<T

>::ok()

Returns whether or not this `absl::StatusOr

<T

>` holds a `T` value. This

member function is analogous to `absl::Status::ok()` and should be used

similarly to check the status of return values.

Example:

StatusOr

<Foo

> result = DoBigCalculationThatCouldFail();

if (result.ok()) {

// Handle result

else {

// Handle error

}

Defined at line 468 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::enable_if_t<internal_statusor::IsValueOrValid<T, U&&, false>::value,
                                           int> = 0>
T value_or (U && default_value)

StatusOr

<T

>::value_or()

Returns the current value if `this->ok() == true`. Otherwise constructs a

value using the provided `default_value`.

Unlike `value`, this function returns by value, copying the current value

if necessary. If the value type supports an efficient move, it can be used

as follows:

T value = std::move(statusor).value_or(def);

Unlike with `value`, calling `std::move()` on the result of `value_or` will

still trigger a copy.

Defined at line 544 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::enable_if_t<internal_statusor::IsValueOrValid<T, U&&, false>::value,
                                           int> = 0>
T value_or (U && default_value)

Defined at line 551 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::enable_if_t<internal_statusor::IsValueOrValid<T, U&&, true>::value,
                                           int> = 0>
T value_or (U && default_value)

Defined at line 558 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::enable_if_t<internal_statusor::IsValueOrValid<T, U&&, true>::value,
                                           int> = 0>
T value_or (U && default_value)

Defined at line 565 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename... Args>
T & emplace (Args &&... args)

StatusOr

<T

>::emplace()

Reconstructs the inner value T in-place using the provided args, using the

T(args...) constructor. Returns reference to the reconstructed `T`.

Defined at line 581 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, typename... Args, absl::enable_if_t<
                              std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value,
                              int> = 0>
T & emplace (std::initializer_list<U> ilist, Args &&... args)

Defined at line 597 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

void StatusOr<T> ()

Constructs a new `absl::StatusOr` with an `absl::StatusCode::kUnknown`

status. This constructor is marked 'explicit' to prevent usages in return

values such as 'return {};', under the misconception that

`absl::StatusOr

<std

::vector

<int

>>` will be initialized with an empty

vector, instead of an `absl::StatusCode::kUnknown` error code.

Defined at line 693 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename... Args>
void StatusOr<T> (absl::in_place_t , Args &&... args)

Constructs the inner value `T` in-place using the provided args, using the

`T(args...)` constructor.

Defined at line 715 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, typename... Args>
void StatusOr<T> (absl::in_place_t , std::initializer_list<U> ilist, Args &&... args)

Defined at line 720 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

const Status & status ()

StatusOr

<T

>::status()

Returns a reference to the current `absl::Status` contained within the

`absl::StatusOr

<T

>`. If `absl::StatusOr

<T

>` contains a `T`, then this

function returns `absl::OkStatus()`.

Defined at line 726 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

Status status ()

Defined at line 730 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

void IgnoreError ()

StatusOr

<T

>::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 735 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

Friends

template <typename U>
class StatusOr