diff options
author | Eli Fox-Epstein <efoxepstein@google.com> | 2021-07-22 18:36:51 +0000 |
---|---|---|
committer | Eli Fox-Epstein <efoxepstein@google.com> | 2021-07-22 18:36:51 +0000 |
commit | fe6237a65de5f3b3b1584f33eef34d9646a93dec (patch) | |
tree | 90457d5ce0b1380cc860e73bf788935651a840d9 | |
parent | 247802334ab523f9dc611fed872833f43d0c9f5a (diff) | |
download | private-join-and-compute-fe6237a65de5f3b3b1584f33eef34d9646a93dec.tar.gz |
Improve util/status_macros.h with ifdef guards.
This also uses operator* instead of .value() to access the value of a
StatusOr known to be OK as per guidance in https://abseil.io/tips/181.
-rw-r--r-- | util/status_macros.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util/status_macros.h b/util/status_macros.h index 005239c..9f83f54 100644 --- a/util/status_macros.h +++ b/util/status_macros.h @@ -24,6 +24,7 @@ // StatusOr with Status OK, and if so assigns the value to the value on the left // hand side (lhs), otherwise returns the error status. Example: // ASSIGN_OR_RETURN(lhs, rexpression); +#ifndef ASSIGN_OR_RETURN #define ASSIGN_OR_RETURN(lhs, rexpr) \ PRIVACY_BLINDERS_ASSIGN_OR_RETURN_IMPL_( \ PRIVACY_BLINDERS_STATUS_MACROS_IMPL_CONCAT_(status_or_value, __LINE__), \ @@ -35,11 +36,13 @@ if (ABSL_PREDICT_FALSE(!statusor.ok())) { \ return std::move(statusor).status(); \ } \ - lhs = std::move(statusor).value() + lhs = *std::move(statusor) +#endif // ASSIGN_OR_RETURN // Helper macro that checks if the given expression evaluates to a // Status with Status OK. If not, returns the error status. Example: // RETURN_IF_ERROR(expression); +#ifndef RETURN_IF_ERROR #define RETURN_IF_ERROR(expr) \ PRIVACY_BLINDERS_RETURN_IF_ERROR_IMPL_( \ PRIVACY_BLINDERS_STATUS_MACROS_IMPL_CONCAT_(status_value, __LINE__), \ @@ -51,6 +54,7 @@ if (ABSL_PREDICT_FALSE(!status.ok())) { \ return status; \ } +#endif // RETURN_IF_ERROR // Internal helper for concatenating macro values. #define PRIVACY_BLINDERS_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) x##y |