19 #ifndef ASYLO_UTIL_STATUS_MACROS_H_ 20 #define ASYLO_UTIL_STATUS_MACROS_H_ 22 #include <type_traits> 25 #include "absl/base/optimization.h" 26 #include "absl/status/status.h" 33 inline constexpr bool HasStatus(
decltype(std::declval<T>().status()) *) {
45 typename std::enable_if<HasStatus<T>(
nullptr),
int>::type = 0>
46 inline auto ToStatus(T&& status_or) ->
decltype(status_or.status()) {
47 return status_or.status();
52 typename std::enable_if<!HasStatus<T>(
nullptr),
int>::type = 0>
73 #define ASYLO_RETURN_IF_ERROR(expr) do 75 auto _asylo_status_to_verify = (expr); 76 if (ABSL_PREDICT_FALSE(!_asylo_status_to_verify.ok())) { 77 return ::asylo::internal::ToStatus( 78 std::forward<decltype(_asylo_status_to_verify)>( 79 _asylo_status_to_verify)); 115 #define ASYLO_ASSIGN_OR_RETURN(lhs, rexpr) 117 auto _asylo_status_or_value = (rexpr); 118 if (ABSL_PREDICT_FALSE(!_asylo_status_or_value.ok())) { 119 return _asylo_status_or_value.status(); 121 lhs = std::move(_asylo_status_or_value).value(); constexpr bool HasStatus(...)
Definition: status_macros.h:39
auto ToStatus(T &&status_or) -> decltype(status_or.status())
Definition: status_macros.h:46
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
Definition: status_macros.h:29
constexpr bool HasStatus(decltype(std::declval< T >().status()) *)
Definition: status_macros.h:33
T ToStatus(T &&status_like)
Definition: status_macros.h:53