|
Asylo
|
#include <type_traits>#include <utility>#include "absl/base/optimization.h"#include "absl/status/status.h"

Go to the source code of this file.
Namespaces | |
| asylo | |
| asylo::internal | |
Macros | |
| #define | ASYLO_RETURN_IF_ERROR(expr) |
Evaluates an expression that produces an Status-like object with a .ok() method. More... | |
| #define | ASYLO_ASSIGN_OR_RETURN(lhs, rexpr) |
Evaluates an expression rexpr that returns a StatusOr-like object with .ok(), .status(), and .value() methods. More... | |
Functions | |
| template<typename T > | |
| constexpr bool | asylo::internal::HasStatus (decltype(std::declval< T >().status()) *) |
| template<typename T > | |
| constexpr bool | asylo::internal::HasStatus (...) |
| template<typename T , typename std::enable_if< HasStatus< T >(nullptr), int >::type = 0> | |
| auto | asylo::internal::ToStatus (T &&status_or) -> decltype(status_or.status()) |
| template<typename T , typename std::enable_if<!HasStatus< T >(nullptr), int >::type = 0> | |
| T | asylo::internal::ToStatus (T &&status_like) |
| #define ASYLO_ASSIGN_OR_RETURN | ( | lhs, | |
| rexpr | |||
| ) |
Evaluates an expression rexpr that returns a StatusOr-like object with .ok(), .status(), and .value() methods.
If the result is OK, moves its value into the variable defined by lhs, otherwise returns the result of the .status() from the current function. The error result of .status is returned unchanged. If there is an error, lhs is not evaluated: thus any side effects of evaluating lhs will only occur if rexpr.ok() is true.
Interface:
Example: Assigning to an existing variable:
Example: Assigning to an expression with side effects:
Example: Assigning to a std::unique_ptr.
| #define ASYLO_RETURN_IF_ERROR | ( | expr | ) |
Evaluates an expression that produces an Status-like object with a .ok() method.
If this method returns false, the object is returned from the current function. If the expression evaluates to a StatusOr object, then it is converted to a Status on return.
Example: