#include "tensorstore/util/result.h"
template <typename Func>
FlatResult<std::invoke_result_t<Func&&, T&>>
tensorstore::Result<T>::operator|(Func&func) const&;
template <typename Func>
FlatResult<std::invoke_result_t<Func&&, T&&>>
tensorstore::Result<T>::operator|(Func&func) &&;

“Pipeline” operator for Result.

In the expression x | y, if

  • x is of type Result<T>

  • y is a function having signature U (T) or Result<U>(T)

Then operator| applies y to the value contained in x, returning a Result<U>. In other words, this function is roughly expressed as:

return !x.ok() ? x.status() : Result<U>(y(x.value()))