template <typename T>

class StatusOr

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

Forward declaration of StatusOr for Status friendship.

Public Methods

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

`StatusOr

<T

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

Defined at line 231 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 234 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 237 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 240 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::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 254 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::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 260 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::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 266 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

template <typename U, std::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 272 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

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

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

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

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

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

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

template <typename U, std::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 323 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

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

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

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

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

template <typename U = absl::Status, std::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 367 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

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

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

template <typename U = T, std::enable_if_t<internal_statusor::IsAssignmentValid<T, U, false>::value,
                                           int> = 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 403 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

template <typename U = T, std::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 435 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

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

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

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

Defined at line 454 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 471 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

absl::Span<const absl::SourceLocation> GetSourceLocations ()

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

void AddSourceLocation (absl::SourceLocation loc)

Appends the `loc` to the current location chain inside the status, iff the

status-or is non-ok and contains a non-empty message.

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

StatusOr<T> && WithSourceLocation (absl::SourceLocation loc)

StatusOr

<T

>::WithSourceLocation()

Appends the `loc` to the current location chain inside the status iff the

status-or is non-ok and contains a non-empty message, and returns an rvalue

reference to `*this`.

Example:

StatusOr

<int

> Finalize(...);

StatusOr

<int

> DoSomething(...) {

...

return Finalize().WithSourceLocation();

}

Defined at line 505 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 577 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 584 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 591 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 598 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 614 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

Defined at line 632 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 730 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

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

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

`T(args...)` constructor.

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

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

Defined at line 757 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 763 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

Status status ()

Defined at line 767 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 772 of file ../../third_party/abseil-cpp/src/absl/status/statusor.h

Friends

template <typename U>
class StatusOr