-
#include "tensorstore/util/status_builder.h" -
template <typename Adaptor>
auto tensorstore::StatusBuilder::With(
Adaptor&&
adaptor) & -> decltype(std::forward<Adaptor>(adaptor)(*this)); -
template <typename Adaptor>
auto tensorstore::StatusBuilder::
With(Adaptor&& adaptor) && -> decltype(std::forward<Adaptor>(
adaptor)(std::move(*this))); Applies a custom
adaptorfunctor to the StatusBuilder.The
adaptorfunctor can be any callable that takes aStatusBuilderor anabsl::Statusas an argument. The primary use cases are applying policies, type conversions, and/or side effects on the StatusBuilder, or converting the returned value of theTENSORSTORE_RETURN_IF_ERRORmacro to another type.Example:
return StatusBuilder(absl::StatusCode::kInvalidArgument) .Format("i=%d", i) .With([](absl::Status status) { LOG(ERROR) << "Error in FunctionWithLogging: " << status; return status; });