-
#include "tensorstore/util/result.h"
-
template <typename U>
T tensorstore::Result<T>::value_or(U&& default_value) const&; -
template <typename U>
T tensorstore::Result<T>::value_or(U&& default_value) &&; Returns the current value if
this->ok() == true
. Otherwise constructs a value using the provideddefault_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
, callingstd::move()
on the result ofvalue_or
will still trigger a copy.