Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
status_macros.h File Reference

Go to the source code of this file.

Macros

#define OR_ASSIGN_OR_RETURN3(lhs, rexpr, error_expression)
 
#define OR_ASSIGN_OR_RETURN3_IMPL_(statusor, lhs, rexpr, error_expression)
 

Macro Definition Documentation

◆ OR_ASSIGN_OR_RETURN3

#define OR_ASSIGN_OR_RETURN3 ( lhs,
rexpr,
error_expression )
Value:
STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __COUNTER__), lhs, rexpr, \
error_expression)
#define STATUS_MACROS_IMPL_CONCAT_(x, y)
#define OR_ASSIGN_OR_RETURN3_IMPL_(statusor, lhs, rexpr, error_expression)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Executes an expression that returns an absl::StatusOr, extracting its value into the variable defined by lhs or returning on error and enabling decorating it with the third argument.

Example: Assigning to an existing value ValueType value; OR_ASSIGN_OR_RETURN3(value, MaybeGetValue(arg), _ << "context"); OR_ASSIGN_OR_RETURN3((auto [key, val]), MaybeGetValue(arg), _ << "with key " << key);

Warning
OR_ASSIGN_OR_RETURN3 expands into multiple statements; it cannot be used in a single statement (e.g. as the body of an if statement without {})!

Definition at line 32 of file status_macros.h.

◆ OR_ASSIGN_OR_RETURN3_IMPL_

#define OR_ASSIGN_OR_RETURN3_IMPL_ ( statusor,
lhs,
rexpr,
error_expression )
Value:
auto statusor = (rexpr); \
if (!statusor.ok()) { \
::util::StatusBuilder _(std::move(statusor).status()); \
return (error_expression); \
} \
STATUS_MACROS_IMPL_UNPARENTHESIS(lhs) = std::move(statusor).value()
absl::Status status
Definition g_gurobi.cc:44

Definition at line 37 of file status_macros.h.